python-codicefiscale
python-codicefiscale is a library for encode/decode Italian fiscal code - codifica/decodifica del Codice Fiscale.
Features
NEWAuto-updated data (once a week) directly from ANPR data-source.- Transliteration for name/surname
- Multiple birthdate formats (date/string) (you can see all the supported string formats here)
- Automatic birthplace city/foreign-country code detection from name
- Omocodia support
Installation
pip install python-codicefiscale
Usage
Import
from codicefiscale import codicefiscale
Encode
codicefiscale.encode(surname='Caccamo', name='Fabio', sex='M', birthdate='03/04/1985', birthplace='Torino')
# 'CCCFBA85D03L219P'
Decode
codicefiscale.decode('CCCFBA85D03L219P')
# {
# 'code': 'CCCFBA85D03L219P',
# 'sex': 'M',
# 'birthdate': datetime.datetime(1985, 4, 3, 0, 0),
# 'birthplace': {
# 'name': 'TORINO'
# 'province': 'TO',
# 'code': 'L219',
# },
# 'omocodes': [
# 'CCCFBA85D03L219P',
# 'CCCFBA85D03L21VE',
# 'CCCFBA85D03L2MVP',
# 'CCCFBA85D03LNMVE',
# 'CCCFBA85D0PLNMVA',
# 'CCCFBA85DLPLNMVL',
# 'CCCFBA8RDLPLNMVX',
# 'CCCFBAURDLPLNMVU',
# ],
# 'raw': {
# 'code': 'CCCFBA85D03L219P',
# 'surname': 'CCC',
# 'name': 'FBA',
# 'birthdate': '85D03',
# 'birthdate_year': '85'
# 'birthdate_month': 'D',
# 'birthdate_day': '03',
# 'birthplace': 'L219',
# 'cin': 'P',
# },
# }
Check
codicefiscale.is_valid('CCCFBA85D03L219P')
# True
codicefiscale.is_omocode('CCCFBA85D03L219P')
# False
Testing
# clone repository
git clone https://github.com/fabiocaccamo/python-codicefiscale.git && cd python-codicefiscale
# create virtualenv and activate it
python -m venv venv && . venv/bin/activate
# upgrade pip
python -m pip install --upgrade pip
# install requirements
pip install -r requirements.txt -r requirements-test.txt
# run tests using tox
tox
# or run tests using unittest
python -m unittest tests.tests
License
Released under MIT License.
Supporting
- ⭐ Star this project on GitHub
- :octocat: Follow me on GitHub
- 💙 Follow me on Twitter
- 💰 Sponsor me on Github
See also
-
python-benedict- dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘 -
python-fontbro- friendly font operations. 🧢 -
python-fsutil- file-system utilities for lazy devs. 🧟♂️
Metadata
Release files for python-codicefiscale 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python-codicefiscale-0.6.1.tar.gz | 406.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_codicefiscale-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 831.0 kB
Release files / python-codicefiscale-0.6.1.tar.gz
| Download URL | python-codicefiscale-0.6.1.tar.gz |
|---|---|
| Size | 406.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
afa1b820161fadcab6acabe14eda3fcf89c4f5c772ff6be684e14455aca6785a
|
|
BLAKE2b-256 checksum How to use checksums |
28722c199fd9b14e7b1f54a60326515cfe00d38db8bf9cb306083792ec4c4119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / python_codicefiscale-0.6.1-py3-none-any.whl
| Download URL | python_codicefiscale-0.6.1-py3-none-any.whl |
|---|---|
| Size | 424.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a38cf82d0f164662fa5a99018d3e0051a518eae515a925df7416f8a3ebf592ac
|
|
BLAKE2b-256 checksum How to use checksums |
1d5294e53bbe13c2f94982ebcec232b5300812e3c65f274203dee9868fe71ab2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|