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/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ utilities.py

2. Usage examples

from Utilities import Utilities

# Validate Portuguese fiscal number
print(Utilities.validate_fiscal_number("287148300"))    # return True

# Validate Portuguese postal code
print(Utilities.validate_postal_code("1231-323"))   # return True

# Get city by telephone prefix
print(Utilities.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/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ utilities.py
โ”œโ”€โ”€ 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.1.tar.gz (9.8 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file core_pt_utilities-0.1.1.tar.gz.

File metadata

  • Download URL: core_pt_utilities-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 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.1.tar.gz
Algorithm Hash digest
SHA256 276386fa93001470e54c65d8867966da6422eb45eea0afefc85bb8a62222fe78
MD5 bd9705c8f51fc5c556d726b8a1b39b9b
BLAKE2b-256 777033078c0a93cb9421ea02071c6393c333ccf06aba1eaf28794314a32839b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for core_pt_utilities-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e20e5fbacfa8bfadac73c9d1a0e0a733b50ba690b3ca330eb35aad7579920fbc
MD5 c55011ed970d252fb7a4e888d05dd62f
BLAKE2b-256 31a7816e7cdfcb5fbf801c2c313aeaad9b62f2521f7c10598123ab5874367895

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