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
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. 🧟♂️
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.8.tar.gz
(135.5 kB
view hashes)
Built Distribution
Close
Hashes for python-codicefiscale-0.3.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c38b856749720c4a0b523065353962a6cee600e0067260b795c7acae51e5cf5a |
|
MD5 | 36de856ef4be19fcba98ed43833eee6d |
|
BLAKE2b-256 | fa1024aadc1c9f34c2222a3621443985f882ae8a3093c90d6d6f13946354bc73 |
Close
Hashes for python_codicefiscale-0.3.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d2d46b4d762f45465862503f24b252d245bfff06c35b154dc24b9a57a483bee |
|
MD5 | 6eee79761090bd17314f67667516ea6d |
|
BLAKE2b-256 | d061dada05eda0fc598ac13ac0ee5927d09132493245af64d57320d86be6c7b0 |