encode / decode italian fiscal codes - codifica / decodifica del Codice Fiscale italiano.
Project description
python-codicefiscale
python-codicefiscale is a library for encode/decode Italian fiscal code - codifica/decodifica del Codice Fiscale.
Features
NEW
Auto-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
# or run tests using setuptools
python setup.py test
License
Released under MIT License.
Supporting
- :star: Star this project on GitHub
- :octocat: Follow me on GitHub
- :blue_heart: Follow me on Twitter
- :moneybag: 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. 🧟♂️
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.6.0.tar.gz
(408.2 kB
view hashes)
Built Distribution
Close
Hashes for python-codicefiscale-0.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbce47cd816a9137792f7ac7053dde627c31569cc88dd19134eda27522c109ac |
|
MD5 | a737d124017cfa4d671bae01fb99f92c |
|
BLAKE2b-256 | 3399ac93cde58ff20f8642557e6d31e008462135e56f8189e182d5183e7a6be1 |
Close
Hashes for python_codicefiscale-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4629a383ebc777c88b565fc197f84937cbf73fd305eb58a07a1c0acd3099cd70 |
|
MD5 | e2d4a126040a888b8a01cd5f7a1ad4da |
|
BLAKE2b-256 | 3b99bad38d3508c3aa855151a71b49cb371df07afe819dcf550dbf99f5036081 |