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)

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.8+Windows x86-64

midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1009f3e5b233960b1b6fa73ea2507f9c835e32e6aa232ced01380eb261482117
MD5 2a2be8cefe6618582e240ceb329ae2f8
BLAKE2b-256 8c32f2d49e2114d04a162993a31f515d1c8991738a7953d06ded943e8e58812c

See more details on using hashes here.

Provenance

The following attestation bundles were made for midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl:

Publisher: mdix-python-pypi-publish.yml on Mid-D-Man/DixScript-Rust

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

File details

Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6d8d4768d489b134b90af4ebbee00eda5781de82e5b3dde08deb67b5714edf5e
MD5 0c179989c95d444f60d75c2c49c4cc03
BLAKE2b-256 19659847474b21b9d2fc174b1562d7dbec7af36897bccb8aa11193b99d2554f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl:

Publisher: mdix-python-pypi-publish.yml on Mid-D-Man/DixScript-Rust

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

File details

Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3522c7ecf095b6de86b900e9897796bf8363d9fa952003ad7dfe1da87d4696ff
MD5 8066d66a6bebca89b8bd999dd42cc17f
BLAKE2b-256 1419779c0b6c22cbcdd5fb653ef25089e83b6bc048094840ac9be7c6eebef4e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: mdix-python-pypi-publish.yml on Mid-D-Man/DixScript-Rust

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

Release history Release notifications | RSS feed

This release

1.0.0 This release

3 files

Supported by

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