Gestión de cédulas uruguayas con validación de dígitos verificadores
Project description
CedulaUruguaya
The CedulaUruguaya package provides a set of tools for managing and validating Uruguayan ID numbers (Cédulas de Identidad). It includes functions to validate these IDs, calculate verification digits, format them in a standard way, and more. This package aims to simplify operations related to Uruguayan IDs in various applications, from data validation to user interface enhancements.
Features
get_validation_digit(ci)
Calculates the verification digit for a given Uruguayan ID number (without the verification digit).
-
Parameters:
ci(int): The ID number without its last verification digit.
-
Returns:
int: The calculated verification digit.
-
Example:
print(CedulaUruguaya.get_validation_digit(3298763)) # Output: 4
clean_ci(ci)
Cleans an ID number by removing non-numeric characters such as dots and dashes.
-
Parameters:
ci(str/int): The ID number as a string or integer, potentially formatted with dots or dashes.
-
Returns:
int: The cleaned numeric ID.
-
Example:
print(CedulaUruguaya.clean_ci("3.298.763-4")) # Output: 32987634
validate_ci(ci)
Validates a complete Uruguayan ID number by comparing its last digit against the calculated verification digit.
-
Parameters:
ci(str/int): The complete ID number.
-
Returns:
bool:Trueif the ID is valid,Falseotherwise.
-
Example:
print(CedulaUruguaya.validate_ci("3.298.763-4")) # Output: True
format_ci(ci)
Formats an ID number into a more visually friendly format (X.XXX.XXX-X).
-
Parameters:
ci(int/str): The ID number to format.
-
Returns:
str: The formatted ID.
-
Example:
print(CedulaUruguaya.format_ci(32987634)) # Output: '3.298.763-4'
random_ci_in_range(start, end)
Generates a random Uruguayan ID number within a specified range, including the verification digit.
-
Parameters:
start(int): Lower bound of the ID range.end(int): Upper bound of the ID range.
-
Returns:
int: A valid ID number.
-
Example:
print(CedulaUruguaya.random_ci_in_range(1000000, 2000000))
international_format(ci)
Converts a local ID format to an international format prefixed with UY-.
-
Parameters:
ci(int/str): The ID number.
-
Returns:
str: The internationally formatted ID.
-
Example:
print(CedulaUruguaya.international_format(32987634)) # Output: 'UY-3.298.763-4'
bulk_validate_ci(ci_list)
Validates a list of IDs in one operation, returning a dictionary with the IDs and their validation results.
-
Parameters:
ci_list(list): A list of complete ID numbers.
-
Returns:
dict: A dictionary with IDs as keys and validation results (TrueorFalse) as values.
-
Example:
print(CedulaUruguaya.bulk_validate_ci(["3.298.763-4", "1.234.567-8"]))
Installation
To install the CedulaUruguaya package, run the following command:
pip install cedula_uruguaya
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cedula_uruguaya-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cedula_uruguaya-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e931d847cc82b3e227752a5dd30280c668f04f8725ccf08831e2b2610ec6630
|
|
| MD5 |
3e64e47d5023f45ac4c25d52a10e5d70
|
|
| BLAKE2b-256 |
3915e2e3b9b36ff22803480471eefb01bf4aa33c2bab1d56c08f713032c75d83
|