# python-iso20022
A Python package that automatically generates and updates dataclasses from ISO20022 schemas daily, making it easy to integrate and validate financial message data.
## Features
- **Daily Updates**: Clones the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) repository at 9 AM CST to retrieve the latest ISO20022 schemas.
- **Dataclass Generation**: Converts ISO20022 schema definitions into Python dataclasses for easy usage.
- **Refactored Code**: Automatically refactors generated dataclass models and associated code for seamless integration.
- **Validation Ready**: Provides tools to validate financial messages against ISO20022 standards.
## **Installation**
To install python-iso20022, run the following command:
```bash
pip install python-iso20022
```
## Repository Structure
```
python-iso20022/
├── .github/workflows # CI/CD workflows
├── python_iso20022/ # Top-level package directory
│ ├── acmt/ # Example of a message set directory
│ │ ├── acmt_001_001_08/ # Directory for a specific message
│ │ │ ├── __init__.py # Standard __init__.py file
│ │ │ ├── enums.py # Enums specific to this message (optional)
│ │ │ ├── models.py # Models for this message
│ │ ├── __init__.py # Standard __init__.py file
│ │ ├── enums.py # Enums specific to this message set (optional)
│ │ ├── parse.py # Parsing functions for messages in the message set
│ ├── __init__.py # Standard __init__.py file
│ ├── enums.py # Enums used across multiple message sets
├── tests/ # Test suite for the package
├── .gitignore # Git ignore file
├── LICENSE # Project license
├── README.md # Project documentation
├── generate.py # Python script that generates all code
├── poetry.lock # Lock file for dependencies
├── pyproject.toml # Project configuration for Poetry
├── requirements-action.txt # Action-specific requirements
```
## How It Works
The `python_iso20022` package leverages the ISO20022 schemas maintained in the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) repository. Every day at 9 AM CST, this repository clones the catalogue and uses its XSD schemas to:
1. Generate Python dataclass models for all messages.
2. Refactor the generated models to ensure consistency and usability.
3. Automatically generate associated code, including parsers and enumerations.
### Message Set Structure
The `python_iso20022` package is organized into directories for each message set, such as `acmt`, `auth`, and `tsrv`. Each message set directory contains subdirectories for specific messages, such as `acmt_001_001_08`. Each message subdirectory contains:
- **`models.py`**: Defines the primary dataclasses for the message.
- **`enums.py` (optional)**: Contains enumerations specific to the message, if applicable.
Each message set directory also contains a `enums.py` file for enums that are shared across multiple messages within the same message set.
Additionally, the top-level `enums.py` file in the `python_iso20022` package contains enums that are used across multiple message sets.
Each message set directory also includes a `parse.py` file, which consolidates imports of all message models in the set and provides parsing functions to deserialize XML sources into the corresponding dataclasses.
### Example
In `python_iso20022/acmt/parse.py`:
```python
from python_iso20022.acmt.acmt_001_001_08.models import Acmt00100108
from python_iso20022.acmt.acmt_002_001_08.models import Acmt00200108
# ... other imports ...
from python_iso20022.utils import XmlSource, read_xml_source
def parse_acmt_001_001_08(source: XmlSource) -> Acmt00100108:
return read_xml_source(source, Acmt00100108)
def parse_acmt_002_001_08(source: XmlSource) -> Acmt00200108:
return read_xml_source(source, Acmt00200108)
```
## Usage
To parse an XML file for a specific message, import the appropriate function from the parsing module of the relevant message set. For example, to parse `acmt_001_001_08`:
```python
from python_iso20022.acmt.parse import parse_acmt_001_001_08
# XML file path
xml_file_path = "path/to/your/file.xml"
# Parse the XML into a dataclass
parsed_message = parse_acmt_001_001_08(xml_file_path)
# Use the parsed dataclass
print(parsed_message)
```
This approach ensures that the XML file is correctly deserialized into the corresponding dataclass for further processing.
### Workflow Details
The GitHub Actions configuration in `.github/workflows` automates daily updates by cloning the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) and processing its schemas.
- **Daily Update Workflow**: Clones the catalogue repository and generates/refactors code based on its schemas at 9 AM CST.
## License
This project is licensed under the terms of the [MIT License](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/galactixx/python-iso20022",
"name": "python-iso20022",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "iso20022, parsing, financial, message",
"author": "galactixx",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/18/5a/ff43926e458be975d14252f836e5ba62ccea814a4494a64af0007ba9dbb8/python_iso20022-0.1.0.tar.gz",
"platform": null,
"description": "# python-iso20022\n\nA Python package that automatically generates and updates dataclasses from ISO20022 schemas daily, making it easy to integrate and validate financial message data.\n\n## Features\n\n- **Daily Updates**: Clones the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) repository at 9 AM CST to retrieve the latest ISO20022 schemas.\n- **Dataclass Generation**: Converts ISO20022 schema definitions into Python dataclasses for easy usage.\n- **Refactored Code**: Automatically refactors generated dataclass models and associated code for seamless integration.\n- **Validation Ready**: Provides tools to validate financial messages against ISO20022 standards.\n\n## **Installation**\n\nTo install python-iso20022, run the following command:\n\n```bash\npip install python-iso20022\n```\n\n## Repository Structure\n\n```\npython-iso20022/\n\u251c\u2500\u2500 .github/workflows # CI/CD workflows\n\u251c\u2500\u2500 python_iso20022/ # Top-level package directory\n\u2502 \u251c\u2500\u2500 acmt/ # Example of a message set directory\n\u2502 \u2502 \u251c\u2500\u2500 acmt_001_001_08/ # Directory for a specific message\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 __init__.py # Standard __init__.py file\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 enums.py # Enums specific to this message (optional)\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 models.py # Models for this message\n\u2502 \u2502 \u251c\u2500\u2500 __init__.py # Standard __init__.py file\n\u2502 \u2502 \u251c\u2500\u2500 enums.py # Enums specific to this message set (optional)\n\u2502 \u2502 \u251c\u2500\u2500 parse.py # Parsing functions for messages in the message set\n\u2502 \u251c\u2500\u2500 __init__.py # Standard __init__.py file\n\u2502 \u251c\u2500\u2500 enums.py # Enums used across multiple message sets\n\u251c\u2500\u2500 tests/ # Test suite for the package\n\u251c\u2500\u2500 .gitignore # Git ignore file\n\u251c\u2500\u2500 LICENSE # Project license\n\u251c\u2500\u2500 README.md # Project documentation\n\u251c\u2500\u2500 generate.py # Python script that generates all code\n\u251c\u2500\u2500 poetry.lock # Lock file for dependencies\n\u251c\u2500\u2500 pyproject.toml # Project configuration for Poetry\n\u251c\u2500\u2500 requirements-action.txt # Action-specific requirements\n```\n\n## How It Works\n\nThe `python_iso20022` package leverages the ISO20022 schemas maintained in the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) repository. Every day at 9 AM CST, this repository clones the catalogue and uses its XSD schemas to:\n\n1. Generate Python dataclass models for all messages.\n2. Refactor the generated models to ensure consistency and usability.\n3. Automatically generate associated code, including parsers and enumerations.\n\n### Message Set Structure\n\nThe `python_iso20022` package is organized into directories for each message set, such as `acmt`, `auth`, and `tsrv`. Each message set directory contains subdirectories for specific messages, such as `acmt_001_001_08`. Each message subdirectory contains:\n\n- **`models.py`**: Defines the primary dataclasses for the message.\n- **`enums.py` (optional)**: Contains enumerations specific to the message, if applicable.\n\nEach message set directory also contains a `enums.py` file for enums that are shared across multiple messages within the same message set.\n\nAdditionally, the top-level `enums.py` file in the `python_iso20022` package contains enums that are used across multiple message sets.\n\nEach message set directory also includes a `parse.py` file, which consolidates imports of all message models in the set and provides parsing functions to deserialize XML sources into the corresponding dataclasses.\n\n### Example\n\nIn `python_iso20022/acmt/parse.py`:\n\n```python\nfrom python_iso20022.acmt.acmt_001_001_08.models import Acmt00100108\nfrom python_iso20022.acmt.acmt_002_001_08.models import Acmt00200108\n# ... other imports ...\nfrom python_iso20022.utils import XmlSource, read_xml_source\n\ndef parse_acmt_001_001_08(source: XmlSource) -> Acmt00100108:\n return read_xml_source(source, Acmt00100108)\n\ndef parse_acmt_002_001_08(source: XmlSource) -> Acmt00200108:\n return read_xml_source(source, Acmt00200108)\n```\n\n## Usage\n\nTo parse an XML file for a specific message, import the appropriate function from the parsing module of the relevant message set. For example, to parse `acmt_001_001_08`:\n\n```python\nfrom python_iso20022.acmt.parse import parse_acmt_001_001_08\n\n# XML file path\nxml_file_path = \"path/to/your/file.xml\"\n\n# Parse the XML into a dataclass\nparsed_message = parse_acmt_001_001_08(xml_file_path)\n\n# Use the parsed dataclass\nprint(parsed_message)\n```\n\nThis approach ensures that the XML file is correctly deserialized into the corresponding dataclass for further processing.\n\n### Workflow Details\n\nThe GitHub Actions configuration in `.github/workflows` automates daily updates by cloning the [ISO20022 Message Catalogue](https://github.com/galactixx/iso20022-message-catalogue) and processing its schemas.\n\n- **Daily Update Workflow**: Clones the catalogue repository and generates/refactors code based on its schemas at 9 AM CST.\n\n## License\n\nThis project is licensed under the terms of the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package that automatically generates and updates dataclasses from ISO20022 schemas daily, making it easy to integrate and validate financial message data",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/galactixx/python-iso20022",
"Repository": "https://github.com/galactixx/python-iso20022"
},
"split_keywords": [
"iso20022",
" parsing",
" financial",
" message"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "715883073443b829ae6a01296dd9a0e1f7e496a29759cfe86f4962befc1312fd",
"md5": "a471263885496794c44b6bb47a97c0e9",
"sha256": "96c16fb0adbc4d1622ad5f357d1dbd6d362c3b5268da332ce1d9b0fd1bf62fbe"
},
"downloads": -1,
"filename": "python_iso20022-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a471263885496794c44b6bb47a97c0e9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 3752426,
"upload_time": "2025-01-17T23:58:48",
"upload_time_iso_8601": "2025-01-17T23:58:48.854883Z",
"url": "https://files.pythonhosted.org/packages/71/58/83073443b829ae6a01296dd9a0e1f7e496a29759cfe86f4962befc1312fd/python_iso20022-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "185aff43926e458be975d14252f836e5ba62ccea814a4494a64af0007ba9dbb8",
"md5": "54681818cce64eb630cb8efa9496defa",
"sha256": "b2caf9d9d748f18904f40e5a419c474083856a525a27ec6c9b0651f6ee7d7bdd"
},
"downloads": -1,
"filename": "python_iso20022-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "54681818cce64eb630cb8efa9496defa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 2903292,
"upload_time": "2025-01-17T23:58:54",
"upload_time_iso_8601": "2025-01-17T23:58:54.565182Z",
"url": "https://files.pythonhosted.org/packages/18/5a/ff43926e458be975d14252f836e5ba62ccea814a4494a64af0007ba9dbb8/python_iso20022-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-17 23:58:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "galactixx",
"github_project": "python-iso20022",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "python-iso20022"
}