Metadata-Version: 2.4
Name: pynetex
Version: 0.1.0
Summary: Python dataclass bindings for the NeTEx 2.0 XML schema
Author-email: jowetmail@gmail.com
License-Expression: GPL-3.0-only
License-File: LICENSE
License-File: NOTICE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: xsdata>=26.2,<27
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# pynetex

`pynetex` provides generated Python dataclasses for reading and writing
[NeTEx](https://netex-cen.eu/) 2.0 XML with
[xsdata](https://xsdata.readthedocs.io/).

The package intentionally exposes the complete generated model at the top
level. Individual generated modules can also be imported directly.

## Installation

```bash
pip install pynetex
```

Python 3.12 or newer is required.

## Usage

Import a model from the complete top-level API:

```python
from pynetex import PublicationDelivery
```

Or import it from its generated module:

```python
from pynetex.publication_delivery import PublicationDelivery
```

Parse and serialize a NeTEx publication with xsdata:

```python
from pathlib import Path

from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig

from pynetex import PublicationDelivery

source = Path("publication.xml")
publication = XmlParser().parse(source, PublicationDelivery)

xml = XmlSerializer(
    config=SerializerConfig(pretty_print=True),
).render(publication)
```

Parsing XML into dataclasses does not perform XML Schema validation. Validate
documents separately when schema conformance is required.

## Schema provenance

The bindings target the NeTEx v2.0 schemas in the `external/NeTEx` submodule,
pinned at commit:

```text
eea28c4424ec37aa3821d34be88b6ef289242b0e
```

The schema source and these generated bindings are distributed under the GNU
General Public License version 3. See `LICENSE` and `NOTICE`.

## Development

Install the locked development environment and run the tests:

```bash
git submodule update --init
uv sync --dev
uv run pytest
```

The Python modules are generated output and should not be edited manually.
Regenerate them from the repository root with xsdata 26.2:

```bash
(
  cd src
  uv run xsdata generate \
    --config ../.xsdata.xml \
    ../external/NeTEx/xsd/NeTEx_publication.xsd
)
```

After regeneration, `git diff --exit-code -- src/pynetex` should report no
changes. To verify a release artifact, build it with `uv build --wheel`, install
the wheel in a clean environment outside the repository, and import `pynetex`.
