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.NEW
Command Line Interface available.- 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
Python
Import
from codicefiscale import codicefiscale
Encode
codicefiscale.encode(
lastname="Caccamo",
firstname="Fabio",
gender="M",
birthdate="03/04/1985",
birthplace="Torino",
)
# "CCCFBA85D03L219P"
Decode
codicefiscale.decode("CCCFBA85D03L219P")
# {
# "code": "CCCFBA85D03L219P",
# "gender": "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",
# "lastname": "CCC",
# "firstname": "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
Command Line
This library can be used also as a CLI tool, for more info run:
python -m codicefiscale --help
Encode (CLI)
python -m codicefiscale encode --firstname Fabio --lastname Caccamo --gender M --birthdate 03/04/1985 --birthplace Torino
Decode (CLI)
python -m codicefiscale decode CCCFBA85D03L219P
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
# install pre-commit to run formatters and linters
pre-commit install --install-hooks
# run tests using tox
tox
# or run tests using unittest
python -m unittest tests.tests
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.10.3.tar.gz
(419.0 kB
view hashes)
Built Distribution
Close
Hashes for python_codicefiscale-0.10.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98b6db2552e2a5b64a84b11977c5a86d36a21d5e0d3437e9f133895f1a5e7e05 |
|
MD5 | f8faa2bc30593575bf2b03cab87efcde |
|
BLAKE2b-256 | 44cee2f4180130db0a0dd1c607e86bfdf40874033b2239517a60c07fe93b070e |
Close
Hashes for python_codicefiscale-0.10.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14f581df6905a3f961aa328a9cc13af602268f60e4351e7c0655e293798809bb |
|
MD5 | 0ce805afac36e1d4c23c97d1a0e11deb |
|
BLAKE2b-256 | 91fcb1dc29ac761dba56739b41d7879843b10d43cd90f6f1dc09430eec08290f |