Centralized and robust service with utilities for the Python ecosystem
Project description
Core Utilities ๐
This component provides essential static methods to simplify repetitive tasks like hide email, validate Portuguese fiscal number, validate Portuguese postal code and other.
โจ Functionalities
- mask_email: Sensitive data protection (GDPR friendly)
- validate_email: Strict formatting verification using Regex.
- format_currency: Conversion of numerical values โโto the European monetary format.
- get_env: Securely read configurations via .env files.
- validate_fiscal_number: Validates the Portuguese taxpayer identification number according to Portuguese standards.
- validate_postal_code: Validates the format of the Portuguese postal code using regular expressions (Regex).
- validate_iban: Validates a Portuguese IBAN (format and MOD 97 check)
- get_city_by_telephone: Returns the city associated with the telephone prefix
๐ ๏ธ How to use
1. Project structure
Copy the Utilities folder to the root of your project:
your_project/
โโโ Utilities/
โ โโโ currency/
โ โโโ env/
โ โโโ validators/
2. Usage examples
from Utilities.validators import fiscal_number
from Utilities.validators import postal_code
from Utilities.validators import telephone
# Validate Portuguese fiscal number
print(fiscal_number.FiscalNumberUtilities.validate_fiscal_number("287148300")) # return True
# Validate Portuguese postal code
print(postal_code.PostalCodeUtilities.validate_postal_code("1231-323")) # return True
# Get city by telephone prefix
print(telephone.TelephonePrefixUtilities.get_city_by_telephone("217676778")) # return Lisboa
๐งช Running Tests
Install pytest:
pip install pytest
Run all tests:
pytest tests/
Expected output:
tests/test_env.py ........ [ 11%]
tests/test_format_currency.py ...... [ 20%]
tests/test_get_city_by_telephone.py ........... [ 36%]
tests/test_mask_email.py ....... [ 46%]
tests/test_validate_email.py ....... [ 56%]
tests/test_validate_fiscal_number.py .......... [ 71%]
tests/test_validate_iban.py .......... [ 85%]
tests/test_validate_postal_code.py .......... [100%]
========================================================================================================== 69 passed in 0.04s ==========================================================================================================
Test coverage
| Test | Description |
|---|---|
test_env |
Read environment variable from .env file |
test_format_currency |
Transform a number into a readable currency format |
test_mask_email |
Transform email 'example@email.com' to 'e******@email.com' |
test_validate_email |
Validate if the email format is valid |
test_validate_fiscal_number |
Validate if the Portuguese fiscal number is valid |
test_validate_iban |
Validate if the Portuguese IBAN is valid |
test_validate_postal_code |
Validate if the Portuguese postal code is valid |
test_get_city_by_telephone |
Returns the city associated with the telephone prefix |
๐ Project Structure
core-utilities/
โโโ Utilities/
โ โโโ currency/
โ โโโ env/
โ โโโ validators/
โโโ tests/
โ โโโ __init__.py
โ โโโ test_env.py
โ โโโ test_format_currency.py
โ โโโ test_mask_email.py
โ โโโ test_validate_email.py
โ โโโ test_validate_fiscal_number.py
โ โโโ test_validate_iban.py
โ โโโ test_validate_postal_code.py
โ โโโ test_get_city_by_telephone.py
โโโ README.md
โโโ LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file core_pt_utilities-0.1.3.tar.gz.
File metadata
- Download URL: core_pt_utilities-0.1.3.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
958fd29264385fc2ee1b78339e8e4e76d5d475b775a29aeb28022b2db282a8cc
|
|
| MD5 |
f4d0932d07288d2f5336ede5e5c2ba5c
|
|
| BLAKE2b-256 |
392192d115fc08d31bcfdfb01bceb4eca32b9c852c164644a48948961039ae95
|
File details
Details for the file core_pt_utilities-0.1.3-py3-none-any.whl.
File metadata
- Download URL: core_pt_utilities-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74cc0ec2e1e74ae94c16e233ae6deeb2ce80780ea6016ad8881da5fe373cf3b0
|
|
| MD5 |
3053b4bf28ec97aa2fdc15e089330e0a
|
|
| BLAKE2b-256 |
9d2da422826a33c086e56e1f6341b766dc5f83337f65cf21c92ea95ecdbcb708
|