Skip to main content

LenexPy

Python toolkit for reading and writing Lenex 3.0 swimming data (.lef/.lxf). Models and validation follow the official Lenex technical documentation (Version 3.0, 4 Mar 2025) — see https://wiki.swimrankings.net/images/6/62/Lenex_3.0_Technical_Documentation.pdf.

What it does

  • Decode/encode Lenex XML (.lef) and zipped Lenex (.lxf).
  • Pydantic + pydantic-xml data models aligned with the 4 Mar 2025 spec (required/optional attributes, timing modes, meet/session/event fields, etc.).
  • JSON helpers to build Lenex objects and emit .lef/.lxf.

Install

pip install lenexpy

Quick start

from lenexpy import fromfile, tofile

lenex = fromfile("meet.lxf")      # .lxf / .lef / .xml
tofile(lenex, "out.lxf")
tofile(lenex, "out.lef")

Work with bytes directly:

from lenexpy.decoder.lef_decoder import decode_lef_bytes
from lenexpy.decoder.lef_encoder import encode_lef_bytes
from lenexpy.decoder.lxf_decoder import decode_lxf_bytes
from lenexpy.decoder.lxf_encoder import encode_lxf_bytes

lenex = decode_lef_bytes(xml_bytes)
xml_bytes = encode_lef_bytes(lenex)

lenex = decode_lxf_bytes(lxf_bytes)
lxf_bytes = encode_lxf_bytes(lenex, "meet.lxf")

Build Lenex from JSON

scripts/parser.py can create Lenex objects from JSON and write Lenex files.

from scripts.parser import create_lenex_from_json_file
from lenexpy import tofile

lenex = create_lenex_from_json_file("meet.json")
tofile(lenex, "meet.lxf")

Minimal JSON shape:

{
  "version": "3.0",
  "constructor": {
    "name": "Bot",
    "version": "1.0.0",
    "contact": {"email": "bot@example.com"}
  },
  "meet": {
    "name": "Test Meet",
    "city": "City",
    "nation": "RUS",
    "sessions": [
      {
        "number": 1,
        "date": "2025-01-01T00:00:00",
        "events": [
          {
            "eventid": 1,
            "number": 1,
            "swimstyle": {
              "distance": 50,
              "relaycount": 1,
              "stroke": "FREE"
            }
          }
        ]
      }
    ]
  }
}

Tests

pytest

Fixture-based round trips live in tests/fixtures. Some third-party fixtures may xfail if they are not spec-conformant (e.g., missing required IDs).

Build

python -m build

Metadata

Release files for lenexpy 3.1.1

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

Source distribution (sdist)

Source distribution for lenexpy 3.1.1
File Size Uploaded
lenexpy-3.1.1.tar.gz 18.1 kB Details

Built distribution (wheel)

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

Total release size: 55.7 kB

Release files / lenexpy-3.1.1.tar.gz

Download URL lenexpy-3.1.1.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
349422f9f42330bf8732d8392e225a6341bcacf9c9196418cde42ecd38ecd090
BLAKE2b-256 checksum
How to use checksums
717709c50bdded3165bce100f6a7642bba666564dc99e11af45779a0063f43dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1018-azure

Release files / lenexpy-3.1.1-py3-none-any.whl

Download URL lenexpy-3.1.1-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6edf59b090c66f8687396b016824905e5a23869adc538a26e7dab9862ddcb51
BLAKE2b-256 checksum
How to use checksums
21385c435bbb86ecd91a8bf760fc93d4adc3af5be5aa01b02c814b7c8c3ff181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1018-azure

Release history Release notifications | RSS feed

This release

3.1.1 This release

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

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