febraban-code


Namefebraban-code JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryFebrabanCode Class for parsing and validating Febraban codes used in Brazil.
upload_time2024-04-24 18:28:06
maintainerNone
docs_urlNone
authorRicardo Castro
requires_pythonNone
licenseMIT
keywords digitable line brazil bar code febraban
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FebrabanCode Class

The `FebrabanCode` class is designed to parse and validate Febraban codes commonly used in Brazil, such as bar codes and lines. This class provides methods to extract information from Febraban codes, validate their integrity, and retrieve specific details.

## Usage

To use this class, follow these steps:

1. **Instantiate the Class**: Create an instance of the `FebrabanCode` class by passing the Febraban code (either bar or line) as a string parameter.

2. **Retrieve Information**: Utilize the provided methods to retrieve information from the Febraban code, such as bank details, currency, value, and expiration date.

3. **Validation**: Use the `validate()` method to check the integrity of the provided Febraban code. This method validates the control digits and ensures the code's correctness.

## Class Methods

### `__init__(bar_code: str)`

Constructor method to initialize the `FebrabanCode` object. It takes a Febraban code (either bar or line) as input.

### `get_code_info() -> Dict[str, Union[str, date, float]]`

Returns a dictionary containing information extracted from the Febraban code, including bank details, currency, expiration date, and value.

### `get_bar() -> str`

Returns the Febraban bar code as a string.

### `get_line(formatted: bool = False) -> str`

Returns the Febraban line code as a string. If `formatted` is set to `True`, the line code is returned with formatting for readability.

### `validate() -> bool`

Validates the integrity of the Febraban code. Returns `True` if the code is valid, otherwise `False`.

## Internal Methods

### `__code_match(code: str) -> str`

Internal method to match and sanitize the input Febraban code.

### `__get_dv_module_10(number: str) -> int`

Calculates the verification digit using the module 10 algorithm.

### `__get_dv_module_11(number: str) -> int`

Calculates the verification digit using the module 11 algorithm.

### `__get_expiry(expiry_factor: str) -> date`

Calculates the expiration date based on the provided expiration factor.

### `__convert_value_factor(value: str) -> float`

Converts the value factor from the Febraban code to a float value.

### `__get_info_from_line(line: str) -> Dict[str, Union[str, date, float]]`

Extracts information from the line code of the Febraban code.

### `__get_info_from_bar(bar: str) -> Dict[str, Union[str, date, float]]`

Extracts information from the bar code of the Febraban code.

### `__get_info_from_code(code: str) -> Dict[str, Union[str, date, float]]`

Determines the type of Febraban code (bar or line) and extracts information accordingly.

## Error Handling

- Raises `AttributeError` if the provided input is not a string.
- Raises `ValueError` if the length of the code is not valid (either 47 digits for the line or 44 digits for the bar).

## Dependencies

- `datetime`: Standard Python library for date and time operations.
- `timedelta`: Standard Python library for representing differences between dates or times.
- `re`: Standard Python library for regular expressions.
- `typing`: Standard Python library for type hints.

## Example

```python
from febraban_code import FebrabanCode

# Instantiate with a Febraban code
febraban_code = FebrabanCode("34191091001219011004141140141141000000120100")

# Retrieve information
info = febraban_code.get_code_info()
print(info)

# Validate the code
is_valid = febraban_code.validate()
print(is_valid)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "febraban-code",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "digitable line, brazil, bar code, febraban",
    "author": "Ricardo Castro",
    "author_email": "srrenks@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/d4/28db3b120b0e5ca1570060c82302ca6d3f83ee55dd6b45f4dc7a9a5f4c5f/febraban_code-0.1.1.tar.gz",
    "platform": null,
    "description": "# FebrabanCode Class\n\nThe `FebrabanCode` class is designed to parse and validate Febraban codes commonly used in Brazil, such as bar codes and lines. This class provides methods to extract information from Febraban codes, validate their integrity, and retrieve specific details.\n\n## Usage\n\nTo use this class, follow these steps:\n\n1. **Instantiate the Class**: Create an instance of the `FebrabanCode` class by passing the Febraban code (either bar or line) as a string parameter.\n\n2. **Retrieve Information**: Utilize the provided methods to retrieve information from the Febraban code, such as bank details, currency, value, and expiration date.\n\n3. **Validation**: Use the `validate()` method to check the integrity of the provided Febraban code. This method validates the control digits and ensures the code's correctness.\n\n## Class Methods\n\n### `__init__(bar_code: str)`\n\nConstructor method to initialize the `FebrabanCode` object. It takes a Febraban code (either bar or line) as input.\n\n### `get_code_info() -> Dict[str, Union[str, date, float]]`\n\nReturns a dictionary containing information extracted from the Febraban code, including bank details, currency, expiration date, and value.\n\n### `get_bar() -> str`\n\nReturns the Febraban bar code as a string.\n\n### `get_line(formatted: bool = False) -> str`\n\nReturns the Febraban line code as a string. If `formatted` is set to `True`, the line code is returned with formatting for readability.\n\n### `validate() -> bool`\n\nValidates the integrity of the Febraban code. Returns `True` if the code is valid, otherwise `False`.\n\n## Internal Methods\n\n### `__code_match(code: str) -> str`\n\nInternal method to match and sanitize the input Febraban code.\n\n### `__get_dv_module_10(number: str) -> int`\n\nCalculates the verification digit using the module 10 algorithm.\n\n### `__get_dv_module_11(number: str) -> int`\n\nCalculates the verification digit using the module 11 algorithm.\n\n### `__get_expiry(expiry_factor: str) -> date`\n\nCalculates the expiration date based on the provided expiration factor.\n\n### `__convert_value_factor(value: str) -> float`\n\nConverts the value factor from the Febraban code to a float value.\n\n### `__get_info_from_line(line: str) -> Dict[str, Union[str, date, float]]`\n\nExtracts information from the line code of the Febraban code.\n\n### `__get_info_from_bar(bar: str) -> Dict[str, Union[str, date, float]]`\n\nExtracts information from the bar code of the Febraban code.\n\n### `__get_info_from_code(code: str) -> Dict[str, Union[str, date, float]]`\n\nDetermines the type of Febraban code (bar or line) and extracts information accordingly.\n\n## Error Handling\n\n- Raises `AttributeError` if the provided input is not a string.\n- Raises `ValueError` if the length of the code is not valid (either 47 digits for the line or 44 digits for the bar).\n\n## Dependencies\n\n- `datetime`: Standard Python library for date and time operations.\n- `timedelta`: Standard Python library for representing differences between dates or times.\n- `re`: Standard Python library for regular expressions.\n- `typing`: Standard Python library for type hints.\n\n## Example\n\n```python\nfrom febraban_code import FebrabanCode\n\n# Instantiate with a Febraban code\nfebraban_code = FebrabanCode(\"34191091001219011004141140141141000000120100\")\n\n# Retrieve information\ninfo = febraban_code.get_code_info()\nprint(info)\n\n# Validate the code\nis_valid = febraban_code.validate()\nprint(is_valid)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "FebrabanCode Class for parsing and validating Febraban codes used in Brazil.",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "digitable line",
        " brazil",
        " bar code",
        " febraban"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "adfbf398a32eb64957637b818c23ad4c57c0dccff90262b0891f3f41e7370463",
                "md5": "f921fed15fd5e73ed31a394f0f61659c",
                "sha256": "294751db0f83cd73188719a267868084b4de812df3aa56297111958c37665e0d"
            },
            "downloads": -1,
            "filename": "febraban_code-0.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f921fed15fd5e73ed31a394f0f61659c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5231,
            "upload_time": "2024-04-24T18:28:04",
            "upload_time_iso_8601": "2024-04-24T18:28:04.643786Z",
            "url": "https://files.pythonhosted.org/packages/ad/fb/f398a32eb64957637b818c23ad4c57c0dccff90262b0891f3f41e7370463/febraban_code-0.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbd428db3b120b0e5ca1570060c82302ca6d3f83ee55dd6b45f4dc7a9a5f4c5f",
                "md5": "6b6de83d34ffaa7fb15dfcaa4e19b433",
                "sha256": "f6e882cce2f3977741051dad07df68f7793fc6ee99247beb7ed223959747c1c5"
            },
            "downloads": -1,
            "filename": "febraban_code-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6b6de83d34ffaa7fb15dfcaa4e19b433",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4407,
            "upload_time": "2024-04-24T18:28:06",
            "upload_time_iso_8601": "2024-04-24T18:28:06.288493Z",
            "url": "https://files.pythonhosted.org/packages/bb/d4/28db3b120b0e5ca1570060c82302ca6d3f83ee55dd6b45f4dc7a9a5f4c5f/febraban_code-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 18:28:06",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "febraban-code"
}
        
Elapsed time: 0.24754s