python-codicefiscale


Namepython-codicefiscale JSON
Version 0.10.0 PyPI version JSON
download
home_page
Summaryencode / decode italian fiscal codes - codifica / decodifica del Codice Fiscale italiano.
upload_time2024-02-19 10:51:08
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) 2017-present Fabio Caccamo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords codicefiscale codice fiscale cf fiscal code italia italy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![](https://img.shields.io/pypi/pyversions/python-codicefiscale.svg?logoColor=white&color=blue&logo=python)](https://www.python.org/)
[![](https://img.shields.io/pypi/v/python-codicefiscale.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/python-codicefiscale/)
[![](https://static.pepy.tech/badge/python-codicefiscale/month)](https://pepy.tech/project/python-codicefiscale)
[![](https://img.shields.io/github/stars/fabiocaccamo/python-codicefiscale?logo=github&style=flat)](https://github.com/fabiocaccamo/python-codicefiscale/stargazers)
[![](https://img.shields.io/pypi/l/python-codicefiscale.svg?color=blue&)](https://github.com/fabiocaccamo/python-codicefiscale/blob/main/LICENSE)

[![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-codicefiscale/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-codicefiscale/main)
[![](https://img.shields.io/github/actions/workflow/status/fabiocaccamo/python-codicefiscale/test-package.yml?branch=main&label=build&logo=github)](https://github.com/fabiocaccamo/python-codicefiscale)
[![](https://img.shields.io/codecov/c/gh/fabiocaccamo/python-codicefiscale?logo=codecov)](https://codecov.io/gh/fabiocaccamo/python-codicefiscale)
[![](https://img.shields.io/codacy/grade/8927f48c9498408f85167da9287edd86?logo=codacy)](https://www.codacy.com/app/fabiocaccamo/python-codicefiscale)
[![](https://img.shields.io/scrutinizer/quality/g/fabiocaccamo/python-codicefiscale?logo=scrutinizer)](https://scrutinizer-ci.com/g/fabiocaccamo/python-codicefiscale/?branch=main)
[![](https://img.shields.io/codeclimate/maintainability/fabiocaccamo/python-codicefiscale?logo=code-climate)](https://codeclimate.com/github/fabiocaccamo/python-codicefiscale/)
[![](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

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

![Codice Fiscale](https://user-images.githubusercontent.com/1035294/72058207-fa77dd80-32cf-11ea-8995-52324e7d3efe.png)

## 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](https://github.com/fabiocaccamo/python-codicefiscale/blob/main/tests/test_codicefiscale.py#L81-L140))*
- **Automatic** birthplace city/foreign-country code detection from name
- **Omocodia** support

## Installation
`pip install python-codicefiscale`

## Usage

### Python

#### Import
```python
from codicefiscale import codicefiscale
```
#### Encode
```python
codicefiscale.encode(
    lastname="Caccamo",
    firstname="Fabio",
    gender="M",
    birthdate="03/04/1985",
    birthplace="Torino",
)

# "CCCFBA85D03L219P"
```
#### Decode
```python
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
```python
codicefiscale.is_valid("CCCFBA85D03L219P")

# True
```
```python
codicefiscale.is_omocode("CCCFBA85D03L219P")

# False
```

### Command Line
This library can be used also as a CLI tool, for more info run:
```bash
python -m codicefiscale --help
```

#### Encode (CLI)
```bash
python -m codicefiscale encode --firstname Fabio --lastname Caccamo --gender M --birthdate 03/04/1985 --birthplace Torino
```

#### Decode (CLI)
```bash
python -m codicefiscale decode CCCFBA85D03L219P
```

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

---

## Supporting

- :star: Star this project on [GitHub](https://github.com/fabiocaccamo/python-codicefiscale)
- :octocat: Follow me on [GitHub](https://github.com/fabiocaccamo)
- :blue_heart: Follow me on [Twitter](https://twitter.com/fabiocaccamo)
- :moneybag: Sponsor me on [Github](https://github.com/sponsors/fabiocaccamo)

## See also

- [`python-benedict`](https://github.com/fabiocaccamo/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`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations. ๐Ÿงข

- [`python-fsutil`](https://github.com/fabiocaccamo/python-fsutil) - file-system utilities for lazy devs. ๐ŸงŸโ€โ™‚๏ธ

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "python-codicefiscale",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "Fabio Caccamo <fabio.caccamo@gmail.com>",
    "keywords": "codicefiscale,codice,fiscale,cf,fiscal code,italia,italy",
    "author": "",
    "author_email": "Fabio Caccamo <fabio.caccamo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b1/95/e7b0023ab06aff494c959873d9219b440a4e3e173cb27205e5c6e52fbbb2/python-codicefiscale-0.10.0.tar.gz",
    "platform": null,
    "description": "[![](https://img.shields.io/pypi/pyversions/python-codicefiscale.svg?logoColor=white&color=blue&logo=python)](https://www.python.org/)\n[![](https://img.shields.io/pypi/v/python-codicefiscale.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/python-codicefiscale/)\n[![](https://static.pepy.tech/badge/python-codicefiscale/month)](https://pepy.tech/project/python-codicefiscale)\n[![](https://img.shields.io/github/stars/fabiocaccamo/python-codicefiscale?logo=github&style=flat)](https://github.com/fabiocaccamo/python-codicefiscale/stargazers)\n[![](https://img.shields.io/pypi/l/python-codicefiscale.svg?color=blue&)](https://github.com/fabiocaccamo/python-codicefiscale/blob/main/LICENSE)\n\n[![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-codicefiscale/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-codicefiscale/main)\n[![](https://img.shields.io/github/actions/workflow/status/fabiocaccamo/python-codicefiscale/test-package.yml?branch=main&label=build&logo=github)](https://github.com/fabiocaccamo/python-codicefiscale)\n[![](https://img.shields.io/codecov/c/gh/fabiocaccamo/python-codicefiscale?logo=codecov)](https://codecov.io/gh/fabiocaccamo/python-codicefiscale)\n[![](https://img.shields.io/codacy/grade/8927f48c9498408f85167da9287edd86?logo=codacy)](https://www.codacy.com/app/fabiocaccamo/python-codicefiscale)\n[![](https://img.shields.io/scrutinizer/quality/g/fabiocaccamo/python-codicefiscale?logo=scrutinizer)](https://scrutinizer-ci.com/g/fabiocaccamo/python-codicefiscale/?branch=main)\n[![](https://img.shields.io/codeclimate/maintainability/fabiocaccamo/python-codicefiscale?logo=code-climate)](https://codeclimate.com/github/fabiocaccamo/python-codicefiscale/)\n[![](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# python-codicefiscale\npython-codicefiscale is a library for encode/decode Italian fiscal code - **codifica/decodifica del Codice Fiscale**.\n\n![Codice Fiscale](https://user-images.githubusercontent.com/1035294/72058207-fa77dd80-32cf-11ea-8995-52324e7d3efe.png)\n\n## Features\n- `NEW` **Auto-updated** data (once a week) directly from **ANPR** data-source.\n- `NEW` **Command Line Interface** available.\n- **Transliteration** for name/surname\n- **Multiple** birthdate formats (date/string) *(you can see all the supported string formats [here](https://github.com/fabiocaccamo/python-codicefiscale/blob/main/tests/test_codicefiscale.py#L81-L140))*\n- **Automatic** birthplace city/foreign-country code detection from name\n- **Omocodia** support\n\n## Installation\n`pip install python-codicefiscale`\n\n## Usage\n\n### Python\n\n#### Import\n```python\nfrom codicefiscale import codicefiscale\n```\n#### Encode\n```python\ncodicefiscale.encode(\n    lastname=\"Caccamo\",\n    firstname=\"Fabio\",\n    gender=\"M\",\n    birthdate=\"03/04/1985\",\n    birthplace=\"Torino\",\n)\n\n# \"CCCFBA85D03L219P\"\n```\n#### Decode\n```python\ncodicefiscale.decode(\"CCCFBA85D03L219P\")\n\n# {\n#     \"code\": \"CCCFBA85D03L219P\",\n#     \"gender\": \"M\",\n#     \"birthdate\": datetime.datetime(1985, 4, 3, 0, 0),\n#     \"birthplace\": {\n#         \"name\": \"TORINO\"\n#         \"province\": \"TO\",\n#         \"code\": \"L219\",\n#     },\n#     \"omocodes\": [\n#         \"CCCFBA85D03L219P\",\n#         \"CCCFBA85D03L21VE\",\n#         \"CCCFBA85D03L2MVP\",\n#         \"CCCFBA85D03LNMVE\",\n#         \"CCCFBA85D0PLNMVA\",\n#         \"CCCFBA85DLPLNMVL\",\n#         \"CCCFBA8RDLPLNMVX\",\n#         \"CCCFBAURDLPLNMVU\",\n#     ],\n#     \"raw\": {\n#         \"code\": \"CCCFBA85D03L219P\",\n#         \"lastname\": \"CCC\",\n#         \"firstname\": \"FBA\",\n#         \"birthdate\": \"85D03\",\n#         \"birthdate_year\": \"85\"\n#         \"birthdate_month\": \"D\",\n#         \"birthdate_day\": \"03\",\n#         \"birthplace\": \"L219\",\n#         \"cin\": \"P\",\n#     },\n# }\n```\n\n#### Check\n```python\ncodicefiscale.is_valid(\"CCCFBA85D03L219P\")\n\n# True\n```\n```python\ncodicefiscale.is_omocode(\"CCCFBA85D03L219P\")\n\n# False\n```\n\n### Command Line\nThis library can be used also as a CLI tool, for more info run:\n```bash\npython -m codicefiscale --help\n```\n\n#### Encode (CLI)\n```bash\npython -m codicefiscale encode --firstname Fabio --lastname Caccamo --gender M --birthdate 03/04/1985 --birthplace Torino\n```\n\n#### Decode (CLI)\n```bash\npython -m codicefiscale decode CCCFBA85D03L219P\n```\n\n## Testing\n```bash\n# clone repository\ngit clone https://github.com/fabiocaccamo/python-codicefiscale.git && cd python-codicefiscale\n\n# create virtualenv and activate it\npython -m venv venv && . venv/bin/activate\n\n# upgrade pip\npython -m pip install --upgrade pip\n\n# install requirements\npip install -r requirements.txt -r requirements-test.txt\n\n# install pre-commit to run formatters and linters\npre-commit install --install-hooks\n\n# run tests using tox\ntox\n\n# or run tests using unittest\npython -m unittest tests.tests\n```\n\n## License\nReleased under [MIT License](LICENSE.txt).\n\n---\n\n## Supporting\n\n- :star: Star this project on [GitHub](https://github.com/fabiocaccamo/python-codicefiscale)\n- :octocat: Follow me on [GitHub](https://github.com/fabiocaccamo)\n- :blue_heart: Follow me on [Twitter](https://twitter.com/fabiocaccamo)\n- :moneybag: Sponsor me on [Github](https://github.com/sponsors/fabiocaccamo)\n\n## See also\n\n- [`python-benedict`](https://github.com/fabiocaccamo/python-benedict) - dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. \ud83d\udcd8\n\n- [`python-fontbro`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations. \ud83e\udde2\n\n- [`python-fsutil`](https://github.com/fabiocaccamo/python-fsutil) - file-system utilities for lazy devs. \ud83e\udddf\u200d\u2642\ufe0f\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2017-present Fabio Caccamo  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "encode / decode italian fiscal codes - codifica / decodifica del Codice Fiscale italiano.",
    "version": "0.10.0",
    "project_urls": {
        "Documentation": "https://github.com/fabiocaccamo/python-codicefiscale#readme",
        "Download": "https://github.com/fabiocaccamo/python-codicefiscale/releases",
        "Funding": "https://github.com/sponsors/fabiocaccamo/",
        "Homepage": "https://github.com/fabiocaccamo/python-codicefiscale",
        "Issues": "https://github.com/fabiocaccamo/python-codicefiscale/issues",
        "Twitter": "https://twitter.com/fabiocaccamo"
    },
    "split_keywords": [
        "codicefiscale",
        "codice",
        "fiscale",
        "cf",
        "fiscal code",
        "italia",
        "italy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02d9276eeb113422039dbf8c19757896ac358be4a0e3a070b7084217ff3e6ffb",
                "md5": "357f4c7f929a668c3814a3da62249369",
                "sha256": "429e196ee249f1c0b64c17232f0b9732f32f18bb7711bfa9a859b90653ab03e6"
            },
            "downloads": -1,
            "filename": "python_codicefiscale-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "357f4c7f929a668c3814a3da62249369",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 430040,
            "upload_time": "2024-02-19T10:51:07",
            "upload_time_iso_8601": "2024-02-19T10:51:07.277288Z",
            "url": "https://files.pythonhosted.org/packages/02/d9/276eeb113422039dbf8c19757896ac358be4a0e3a070b7084217ff3e6ffb/python_codicefiscale-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b195e7b0023ab06aff494c959873d9219b440a4e3e173cb27205e5c6e52fbbb2",
                "md5": "842ab91aaf250e4cb68e99b9c31d9280",
                "sha256": "865883fa65f803f20630038944c759332f19eaa1bd9b742a103c8ca7e2593b14"
            },
            "downloads": -1,
            "filename": "python-codicefiscale-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "842ab91aaf250e4cb68e99b9c31d9280",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 418317,
            "upload_time": "2024-02-19T10:51:08",
            "upload_time_iso_8601": "2024-02-19T10:51:08.953732Z",
            "url": "https://files.pythonhosted.org/packages/b1/95/e7b0023ab06aff494c959873d9219b440a4e3e173cb27205e5c6e52fbbb2/python-codicefiscale-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-19 10:51:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fabiocaccamo",
    "github_project": "python-codicefiscale#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "python-codicefiscale"
}
        
Elapsed time: 0.20157s