Skip to main content

pynetex

pynetex provides generated Python dataclasses for reading and writing NeTEx 2.0 XML with xsdata.

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

Installation

pip install pynetex

Python 3.12 or newer is required.

Usage

Import a model from the complete top-level API:

from pynetex import PublicationDelivery

Or import it from its generated module:

from pynetex.publication_delivery import PublicationDelivery

Parse and serialize a NeTEx publication with xsdata:

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:

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:

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:

(
  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.

Metadata

Release files for pynetex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pynetex 0.1.0
File Interpreter ABI Platform
pynetex-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / pynetex-0.1.0-py3-none-any.whl

Download URL pynetex-0.1.0-py3-none-any.whl
Size 3.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a3967d6f2a839cf5f60a20b574c4f054c9a70d81f73683aa00c22949e8960589
BLAKE2b-256 checksum
How to use checksums
f00e0c0b42a2fccef2d95b7eae5a94b139ac4943f349b97a013d9ff8ecdec665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page