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 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:
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)
│ ├── __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 repository. Every day at 9 AM CST, this repository clones the catalogue and uses its XSD schemas to:
- Generate Python dataclass models for all messages.
- Refactor the generated models to ensure consistency and usability.
- 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 and auth, among others. 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.
Usage
To parse an XML file for a specific message, import the appropriate class from either the module of the relevant message set or specific message.
from python_iso20022.acmt import Acmt00100108
or
from python_iso20022.acmt.acmt_001_001_08 import Acmt00100108
For example, to parse an XML file representing the acmt.001.001.08 message:
from python_iso20022.acmt import Acmt00100108
# XML file path
xml_file_path = "path/to/your/file.xml"
# Parse the XML into a dataclass
parsed_message = Acmt00100108.from_iso20022_xml(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.
Models Overview
Each generated dataclass inherits from one of the below classes.
ISO20022Message
This subclass represents a top-level ISO20022 message and provides additional functionality specific to complete ISO20022 XML documents.
Methods:
write_to_iso20022_xml(path: Path) -> None: Writes the XML representation to a specified file.
ISO20022MessageElement
This subclass represents individual components of an ISO20022 message. It is designed for use within the context of a larger message.
Each class above inherits from AbstractISO20022Model which provides access to the following methods:
to_iso20022_xml(pretty_print: bool = True) -> str: Abstract method for serializing the instance to an ISO20022-compliant XML string.deep_copy() -> AbstractISO20022Model: Creates and returns a deep copy of the instance.from_iso20022_xml(source: Union[str, Path, bytes, IO]) -> AbstractISO20022Model: Class method for creating an instance from an ISO20022 XML source.to_json(pretty_print: bool = True) -> str: Serializes the instance to a JSON string.is_equal_to(other: AbstractISO20022Model) -> bool: Compares two instances by their XML representation.
Workflow Details
The GitHub Actions configuration in .github/workflows automates daily updates by cloning the 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.
Metadata
Release files for python-iso20022 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_iso20022-0.3.0.tar.gz | 2.9 MB | Without provenance | Details for python_iso20022-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_iso20022-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for python_iso20022-0.3.0-py3-none-any.whl |
Total release size: 6.7 MB
Release files / python_iso20022-0.3.0.tar.gz
| Download URL | python_iso20022-0.3.0.tar.gz |
|---|---|
| Size | 2.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34149d0c6e3bc7ac28cd4b584ef05e0d3446e819d9953d9b3fb606d958bf7cbe
|
|
BLAKE2b-256 checksum How to use checksums |
3dcbc7466712a1a111d385bd4cce8e6db5f3723d0dca062f658da172b14415f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Windows/11
|
Release files / python_iso20022-0.3.0-py3-none-any.whl
| Download URL | python_iso20022-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd034982a29047d3aae4af5659fa4cff68522d17436ab3312e26875527b900f5
|
|
BLAKE2b-256 checksum How to use checksums |
8b7514d282311c59466c85eb76b43090e6a8a6ae5617c6fbfe5daceb266c5bb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Windows/11
|
Security for python-iso20022 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.