python-codicefiscale
python-codicefiscale is a tiny library for encode/decode Italian fiscal code - codifica/decodifica del Codice Fiscale.
Features
- Transliteration for name/surname
- Multiple birthdate formats (datetime/string) (you can see all the supported string formats in
tests/tests.py) - 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
# create python virtual environment
virtualenv testing_codicefiscale
# activate virtualenv
cd testing_codicefiscale && . bin/activate
# clone repo
git clone https://github.com/fabiocaccamo/python-codicefiscale.git src && cd src
# install requirements
pip install -r requirements.txt
pip install -r requirements-test.txt
# run tests using tox
tox
# or run tests using unittest
python -m unittest tests.tests
# or run tests using setuptools
python setup.py test
License
Released under MIT License.
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. 🧟♂️
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 python-codicefiscale-0.3.9.tar.gz.
File metadata
- Download URL: python-codicefiscale-0.3.9.tar.gz
- Upload date:
- Size: 135.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92c5c66582fc54fcd7f1573d0424ef263a4511e9e97fdc6d6a88141e901a024c
|
|
| MD5 |
906dc043d130f54a202d7c4b8a64651a
|
|
| BLAKE2b-256 |
b76536c0f493eaa15a40067cd82747c6f107149643a53dce8205ed71b6360b8f
|
File details
Details for the file python_codicefiscale-0.3.9-py3-none-any.whl.
File metadata
- Download URL: python_codicefiscale-0.3.9-py3-none-any.whl
- Upload date:
- Size: 139.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
168af7ea69787ab2f8bb0c468e98c9b4879c921baa5510120277a4d7b35104b5
|
|
| MD5 |
59a54ed1d66d3f597413642bc816070a
|
|
| BLAKE2b-256 |
4aaec9cc3904f4784dd6788b4543df377ae093d50d261069d3b26556050ae69d
|