python-codicefiscale
python-codicefiscale is a library for encode/decode Italian fiscal code - codifica/decodifica del Codice Fiscale.
Features
NEWAuto-updated data (once a week) directly from ANPR data-source.NEWCommand 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 this project on GitHub
- :octocat: Follow me on GitHub
- 💙 Follow me on Twitter
- 💰 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. 🧟♂️
Metadata
Release files for python-codicefiscale 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python-codicefiscale-0.9.1.tar.gz | 418.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_codicefiscale-0.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 848.1 kB
Release files / python-codicefiscale-0.9.1.tar.gz
| Download URL | python-codicefiscale-0.9.1.tar.gz |
|---|---|
| Size | 418.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb1d1442ef3d1f72034e58a602b325d151b0a24bda9c09bac260a9b19ad3b8f9
|
|
BLAKE2b-256 checksum How to use checksums |
abc45c5d7eea23128a3fd6eb3cc78f6db8248ca43a66924292d958852b5b32c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / python_codicefiscale-0.9.1-py3-none-any.whl
| Download URL | python_codicefiscale-0.9.1-py3-none-any.whl |
|---|---|
| Size | 430.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de75ed83933b5bab699a3a5515f3781364984cb00563ddc3b4bd20d42f0f03c2
|
|
BLAKE2b-256 checksum How to use checksums |
39573996c9ab1a21f81eb94d963d8ffdf68dbc83d8e683cf2a4d13bc112ef26d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|