Skip to main content

Centralized and robust service with utilities for the Python ecosystem

Project description

Core Utilities ๐Ÿš€

Python Version Tests License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

core_pt_utilities-0.1.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

core_pt_utilities-0.1.3-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

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

Hashes for core_pt_utilities-0.1.3.tar.gz
Algorithm Hash digest
SHA256 958fd29264385fc2ee1b78339e8e4e76d5d475b775a29aeb28022b2db282a8cc
MD5 f4d0932d07288d2f5336ede5e5c2ba5c
BLAKE2b-256 392192d115fc08d31bcfdfb01bceb4eca32b9c852c164644a48948961039ae95

See more details on using hashes here.

File details

Details for the file core_pt_utilities-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for core_pt_utilities-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 74cc0ec2e1e74ae94c16e233ae6deeb2ce80780ea6016ad8881da5fe373cf3b0
MD5 3053b4bf28ec97aa2fdc15e089330e0a
BLAKE2b-256 9d2da422826a33c086e56e1f6341b766dc5f83337f65cf21c92ea95ecdbcb708

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page