Skip to main content

midmanstudio-mdix

Python runtime for DixScript (.mdix) — MidManStudio.

Installation

pip install midmanstudio-mdix

Quick start

from midmanstudio.mdix import MdixDatabase, MdixBuilder, MdixError, MdixResult

# Load and read — raises on error
with MdixDatabase.load_str('@DATA( port = 8080, host = "localhost" )') as db:
    port = db.get_int("port")
    host = db.get_string("host", "localhost")   # default if missing
    keys = db.get_keys()

# Railway style — never raises
result = (MdixDatabase.try_load_str(source)
          .and_then(lambda db: db.try_get_int("port"))
          .ensure(lambda p: p > 1024, "port must be > 1024")
          .map(lambda p: p * 2)
          .unwrap_or(3000))

# Builder — two-tier ordering enforced
db = (MdixBuilder()
      .set_config("version", "1.0.0")
      .add_enum("LogLevel", ["DEBUG", "INFO", "WARN", "ERROR"])
      # tier 1: flat properties must come first
      .set_string("app_name", "MyGame")
      .set_int("port", 8080)
      .set_bool("ssl", True)
      .set_enum("log_level", "LogLevel", "INFO")
      # tier 2: grouped after all flat
      .with_table_properties("server", {"host": "localhost", "port": 8080})
      .with_group_array("enemies", [
          {"name": "Goblin", "hp": 50},
          {"name": "Orc",    "hp": 100},
      ])
      .to_database())

# Foreign format import
db2 = MdixDatabase.from_json('{"port": 8080, "host": "localhost"}')
db3 = MdixDatabase.from_toml('port = 8080\nhost = "localhost"\n')

# Export
json_str = db.to_json(indented=True)
toml_str = db.to_toml()
mdix_str = db.to_mdix()

MdixResult — railway programming

# Chain operations without try/except
value = (MdixDatabase.try_load("config.mdix")
         .and_then(lambda db: db.try_get_string("server.host"))
         .map(str.upper)
         .tap(lambda v: print(f"host = {v}"))
         .unwrap_or("UNKNOWN"))

# fold — explicit success/failure branches
message = result.fold(
    on_success=lambda v: f"Loaded: {v}",
    on_failure=lambda e: f"Failed: {e}",
)

# bool(result) is True for success
if result:
    print(result.value)

MdixQuery — LINQ-style querying

db = MdixDatabase.load_str("""
@DATA(
  tasks::
  { name = "Backup", priority = 3 },
  { name = "Docs",   priority = 1 },
  { name = "Audit",  priority = 3 }
)
""")

high_priority = (db.query("tasks")
                  .where_(lambda t: t["priority"] == 3)
                  .order_by_desc(lambda t: t["priority"]))
names = high_priority.select(lambda t: t["name"])   # ["Backup", "Audit"]

# Sibling paths sharing shape via a wildcarded segment
statuses = db.query_many("servers.*.status")

# MdixQuery also supports len(), indexing, and iteration directly
for task in db.query("tasks"):
    print(task["name"])

db.query(path) covers a plain array literal or a GroupArray's items alike, and returns None (not an error) if path doesn't exist or isn't an array. Every predicate/key/selector is a plain Python callable — where_, where_field_eq, select, select_field, order_by, order_by_desc, group_by, distinct, skip, take, any, all, count, is_empty, first/first_or/last/nth, sum_int/sum_float/ avg_float, min_by_key/max_by_key, and to_list.

MdixWatcher — hot reload

from midmanstudio.mdix import MdixWatcher

watcher = MdixWatcher("config.mdix")

# in your own update loop / tick / timer callback:
db, changed = watcher.check()
if changed:
    apply_new_config(db)

Poll-based, not OS-event-based — a single stat call per check(), cheap enough to run every frame and consistent across every platform. The first check() always reports a change; db is None when changed is False. Use force_reload() to reload unconditionally, or has_changed() to check without reloading.

Requirements

  • Python 3.8+
  • No Rust toolchain required (pre-built wheels provided)

Metadata

Release files for midmanstudio-mdix 1.0.0

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

Built distributions (wheels)

Table of built distributions (wheels) for midmanstudio-mdix 1.0.0
File Interpreter ABI Platform
midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details
midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 11.9 MB

Release files / midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl

Download URL midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl
Size 4.2 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1009f3e5b233960b1b6fa73ea2507f9c835e32e6aa232ced01380eb261482117
BLAKE2b-256 checksum
How to use checksums
8c32f2d49e2114d04a162993a31f515d1c8991738a7953d06ded943e8e58812c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.

Transparency log

Release files / midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
6d8d4768d489b134b90af4ebbee00eda5781de82e5b3dde08deb67b5714edf5e
BLAKE2b-256 checksum
How to use checksums
19659847474b21b9d2fc174b1562d7dbec7af36897bccb8aa11193b99d2554f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.

Transparency log

Release files / midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
Size 3.7 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3522c7ecf095b6de86b900e9897796bf8363d9fa952003ad7dfe1da87d4696ff
BLAKE2b-256 checksum
How to use checksums
1419779c0b6c22cbcdd5fb653ef25089e83b6bc048094840ac9be7c6eebef4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

3 release files

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