Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🇮🇹 💳 italian fiscal codes encoding, decoding and validation - codifica, decodifica e validazione del Codice Fiscale italiano.

License

NotificationsYou must be signed in to change notification settings

fabiocaccamo/python-codicefiscale

Repository files navigation

python-codicefiscale

python-codicefiscale is a library for encode/decode Italian fiscal code -codifica/decodifica del Codice Fiscale.

Codice Fiscale

Features

  • NEWAuto-updated data (once a week) directly fromANPR data-source.
  • NEWCommand Line Interface available.
  • Transliteration for name/surname
  • Multiple birthdate formats (date/string)(you can see all the supported string formatshere)
  • Automatic birthplace city/foreign-country code detection from name
  • Omocodia support

Installation

pip install python-codicefiscale

Usage

Python

Import

fromcodicefiscaleimportcodicefiscale

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 repositorygit clone https://github.com/fabiocaccamo/python-codicefiscale.git&&cd python-codicefiscale# create virtualenv and activate itpython -m venv venv&&. venv/bin/activate# upgrade pippython -m pip install --upgrade pip# install requirementspip install -r requirements.txt -r requirements-test.txt# install pre-commit to run formatters and linterspre-commit install --install-hooks# run tests using toxtox# or run tests using pytestpytest

License

Released underMIT License.


Supporting

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. 🧟‍♂️

About

🇮🇹 💳 italian fiscal codes encoding, decoding and validation - codifica, decodifica e validazione del Codice Fiscale italiano.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors10

Languages


[8]ページ先頭

©2009-2025 Movatter.jp