Popularity
1.2
Growing
Activity
1.8
-
36
2
11

Description

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

Programming language: Python
License: MIT License
Latest version: v0.3.7

python-codicefiscale alternatives and similar packages

Based on the "Data Validation" category.
Alternatively, view python-codicefiscale alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of python-codicefiscale or a related project?

Add another 'Data Validation' Package

README

python-codicefiscale

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

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

# 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](LICENSE.txt).


*Note that all licence references and agreements mentioned in the python-codicefiscale README section above are relevant to that project's source code only.