python-codicefiscale is a tiny library for encode/decode Italian fiscal code - codifica/decodifica del Codice Fiscale.
Project description
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
Test
tox
/ python setup.py test
/ python -m unittest tests.tests
License
Released under MIT 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
python-codicefiscale-0.3.6.tar.gz
(131.0 kB
view hashes)
Built Distribution
Close
Hashes for python-codicefiscale-0.3.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d345148d4fa48fe563cf659250869f5d95c9fb154d54b70b63e914db1796b251 |
|
MD5 | 4aa0b468c573b63c77d7060bd111aea3 |
|
BLAKE2b-256 | 56adcb49ed4753e5b80711a1b11753ca9fdb43fb6be14ff0effda4ec42aaa068 |
Close
Hashes for python_codicefiscale-0.3.6-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c422d52462022aae72e85829bb837f3bbe3db162c4f52fb169ed4938f65c6de |
|
MD5 | 2956e7704379c7882d9756e226de9bf3 |
|
BLAKE2b-256 | ad887edb810c86f7176f02aa30ffb3d57d11dfd07983887f17d7c1308c1b7a6b |