Skip to main content

Python package for validating Uruguayan identity document numbers.

Project description

ciuy

PyPI PyPI - Status Build Status Coverage Status Documentation Status PyPI - License

🇺🇾 🇪🇸 Documentación en español disponible aquí / Spanish documentation is available here.


Package for validating Uruguayan identity document numbers. Full documentation is available here.

The functions in this package work with strings and ignore any non-digit characters. Numbers are valid too. So for example, the following expressions represent the same document number:

'1.234.567-2'
'12345672'
12345672

This package includes the following functions:

validate_ci(ci: str) -> bool: Returns true if ci is a valid document number, returns false otherwise. ci is a string which represents a document number, including the validation digit. ci can be a number as well.

validation_digit(ci: str) -> str: Returns the validation digit for ci.

random() -> str: Returns a random document number (including validation digit) in the (100.000, 9.999.999) range.

Installation

$ pip install ciuy

Usage

>>> import ciuy
>>> ciuy.validate_ci("1.234.567-2")
True
>>> ciuy.validation_digit("1.234.567")
'2'
>>> ciuy.random()
'82405816'

Testing

This package includes some doctests, as well as unit tests that can be run with pytest.

After cloning the repository, you can run the doctests with:

$ python3 -m doctest ./ciuy/__init__.py -v
 (several lines ommited)
11 passed and 0 failed.
Test passed.

Use py.test to run the unit tests:

$ py.test
============================= test session starts ==============================
platform linux -- Python 3.8.1, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /home/ciuy
collected 73 items                                                             

tests/test_clean.py ..........                                           [ 13%]
tests/test_random.py ..                                                  [ 16%]
tests/test_validate_ci.py ......................................         [ 68%]
tests/test_validation_digit.py .......................                   [100%]

============================== 97 passed in 1.09s =============================

You can also use pytest to run all tests, including doctests, with:

$ py.test --doctest-modules

Command line

After installation, the following commands become available:

$ validate_ci 1.234.567-2
True
$ validation_digit 1.234.567
2
$ random_ci
82405816

Based on the ci_uy Ruby gem by Fernando Briano (link).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ciuy-0.5.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ciuy-0.5.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file ciuy-0.5.0.tar.gz.

File metadata

  • Download URL: ciuy-0.5.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.4

File hashes

Hashes for ciuy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c3d78e2edd9eb42a284ba6e6980b8d0423082950399c5f4048bb4bd7982d1761
MD5 66a6b19dc5ab1b7a7c305283b934e44e
BLAKE2b-256 179a10d4f91bca00811f593b827baf5ad376dce7cd0ce26025167e6624bb412e

See more details on using hashes here.

File details

Details for the file ciuy-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ciuy-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.4

File hashes

Hashes for ciuy-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ece8b08cde967a9620f8180b7dce960a6b2b097530e0638f6123e2e422bd4dd0
MD5 f4a07cc50674d7be28ce0cb7e728dfd6
BLAKE2b-256 ce0d806b8d05ae5466a699f742be6aef1118693e9e9fc9cea0c0bc9921c427c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page