Skip to main content

Model tournament knockout stages in JSON format and render the schedule in SVG or html table format

Project description

matamata

PyPI Python versions CI Docs License: MIT

Model a tournament knockout stage in a small JSON "language" and render the schedule in SVG or HTML table format.

matamata also lets a host system map documents representing championship knockout stages onto its own business objects (e.g. a Championship or Cup entity) and persist them apart from any presentation concern — updating results means editing a document, never the code.

Example rendered from examples/libertadores-2026.json:

Copa Libertadores 2026 knockout stage

Quickstart

Requires Python ≥ 3.10. No runtime dependencies.

git clone https://github.com/anibalpacheco/matamata.git
cd matamata
python -m venv .venv && source .venv/bin/activate
pip install -e .

Render a self-contained example to an SVG file:

# via the installed command
matamata examples/knockout-8.json -o knockout.svg

# or via the module, writing to stdout
python -m matamata examples/knockout-8.json > knockout.svg

# or as an HTML table, the layout for small screens
matamata examples/knockout-8.json -o knockout.html

Open the resulting file in a browser to view the schedule. To render your own cup, point the command at any JSON file that follows docs/format.md.

Use it from Python:

from matamata import load_stage, render_svg

svg = render_svg(load_stage("examples/knockout-8.json"))

To use it in your own project instead, install from PyPI:

pip install matamata

(or pip install git+https://github.com/anibalpacheco/matamata.git for the latest unreleased commit).

Examples

Both examples are rendered from the JSON files in examples/.

The Copa Libertadores example above shows two-legged ties — each leg's goals are shown, shootouts appear in parentheses, and the winner of each tie is emphasized. The first quarterfinal is host-resolved: its legs carry only a ref, so its teams and scores come from get_match (see examples/libertadores_host.py) rather than from the document. Played ties take their team names from the legs; the final is a single match — one leg, so just one goal figure per side — with its winnerof links wiring the advancement tree.

Single matches (knockout-8.json) — one goal figure per side, with shootouts in parentheses. Sides that have not been resolved yet fall back to placeholders such as "Winner SF2":

World Cup knockout stage

The format

The document is plain JSON, so any system can store and exchange it natively, and the language is designed so a match can evolve from a placeholder (e.g. "winner of QF1") into a reference to a real match entity — each leg can carry a ref to the real game, resolved dynamically by the host — without changing the language. The advancement tree is laid out deterministically: coordinates are computed directly and the SVG is emitted as a string, with no layout engine and no heavy dependencies.

See docs/format.md for the full specification and docs/schema.json for the JSON Schema. Worked examples live in examples/.

Minimal example:

{
  "tournament": "Copa Libertadores",
  "season": "2026",
  "rounds": [
    {
      "name": "Final",
      "matches": [
        {
          "id": "final",
          "legs": [
            { "team1": "Flamengo", "goals1": 1, "team2": "Nacional", "goals2": 2 }
          ],
          "winner": 2
        }
      ]
    }
  ]
}

Documentation

docs/index.md is the manual: rendering from the CLI and from Python (e.g. a Django view), feeding live data from your own database through KnockoutStage, updating the stored document with apply_results — including a before/after walkthrough of one call — and running the test suite.

Status

Working: the language spec, JSON Schema, Python renderer, CLI and tests are in place, and the package is installable from GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matamata-0.0.3.tar.gz (637.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matamata-0.0.3-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file matamata-0.0.3.tar.gz.

File metadata

  • Download URL: matamata-0.0.3.tar.gz
  • Upload date:
  • Size: 637.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for matamata-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fb856e8f30858cbf46563d2aee8319811da5338101f2277533db0ba3739368ab
MD5 b579a2470e3246075d70f4e5c59a9d06
BLAKE2b-256 f43aba15a70b2f34d7a73372f2cc9f59386bce4aacfca7eeaef5a16c34200353

See more details on using hashes here.

Provenance

The following attestation bundles were made for matamata-0.0.3.tar.gz:

Publisher: release.yml on anibalpacheco/matamata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matamata-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: matamata-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for matamata-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb8964bbcfa59c2d557bd85c1145c71139855f40590a9266d84dd0c2f77aa76
MD5 223e2cd536bcbbc6dbf80f3ceac886f8
BLAKE2b-256 90a7266aea789e23d0978cb0718d2d60436f1219f7b74213c3bba374b17a0d6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for matamata-0.0.3-py3-none-any.whl:

Publisher: release.yml on anibalpacheco/matamata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page