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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1009f3e5b233960b1b6fa73ea2507f9c835e32e6aa232ced01380eb261482117
|
|
| MD5 |
2a2be8cefe6618582e240ceb329ae2f8
|
|
| BLAKE2b-256 |
8c32f2d49e2114d04a162993a31f515d1c8991738a7953d06ded943e8e58812c
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midmanstudio_mdix-1.0.0-cp38-abi3-win_amd64.whl -
Subject digest:
1009f3e5b233960b1b6fa73ea2507f9c835e32e6aa232ced01380eb261482117 - Sigstore transparency entry: 2312714026
- Sigstore integration time:
-
Permalink:
Mid-D-Man/DixScript-Rust@ee75e20a391bd00d120a329c87df8612dd27e10d -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Mid-D-Man
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
mdix-python-pypi-publish.yml@ee75e20a391bd00d120a329c87df8612dd27e10d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.8+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d8d4768d489b134b90af4ebbee00eda5781de82e5b3dde08deb67b5714edf5e
|
|
| MD5 |
0c179989c95d444f60d75c2c49c4cc03
|
|
| BLAKE2b-256 |
19659847474b21b9d2fc174b1562d7dbec7af36897bccb8aa11193b99d2554f1
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midmanstudio_mdix-1.0.0-cp38-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
6d8d4768d489b134b90af4ebbee00eda5781de82e5b3dde08deb67b5714edf5e - Sigstore transparency entry: 2312714053
- Sigstore integration time:
-
Permalink:
Mid-D-Man/DixScript-Rust@ee75e20a391bd00d120a329c87df8612dd27e10d -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Mid-D-Man
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
mdix-python-pypi-publish.yml@ee75e20a391bd00d120a329c87df8612dd27e10d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3522c7ecf095b6de86b900e9897796bf8363d9fa952003ad7dfe1da87d4696ff
|
|
| MD5 |
8066d66a6bebca89b8bd999dd42cc17f
|
|
| BLAKE2b-256 |
1419779c0b6c22cbcdd5fb653ef25089e83b6bc048094840ac9be7c6eebef4e0
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midmanstudio_mdix-1.0.0-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
3522c7ecf095b6de86b900e9897796bf8363d9fa952003ad7dfe1da87d4696ff - Sigstore transparency entry: 2312714045
- Sigstore integration time:
-
Permalink:
Mid-D-Man/DixScript-Rust@ee75e20a391bd00d120a329c87df8612dd27e10d -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Mid-D-Man
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
mdix-python-pypi-publish.yml@ee75e20a391bd00d120a329c87df8612dd27e10d -
Trigger Event:
workflow_dispatch
-
Statement type: