build:
uv pip compile pyproject.toml -o requirements.txt
- uv run shiv -o pacman -e pacman:main -r requirements.txt .
- tar czf "$$(uv version).tgz" pacman config.json
+ uv run shiv -o "$$(uv version)" -e pacman:main -r requirements.txt .
+ tar czf "$$(uv version).tgz" "$$(uv version)" config.json

-
\ No newline at end of file
+
from collections.abc import Callable
from dataclasses import dataclass
from enum import Enum, auto
+from pathlib import Path
from typing import cast, override
from mazegenerator import ( # type: ignore[import-untyped, unused-ignore]
def load_config(world: World) -> None:
"""Load the configuration json."""
- if len(sys.argv) != 2:
+ if len(sys.argv) > 2:
raise Exception(
- f"Expected exactly 1 argument, got {len(sys.argv) - 1}"
+ f"Expected at most 1 argument, the config, got {len(sys.argv) - 1}"
)
+ s = Config().model_dump_json()
+ if len(sys.argv) == 1:
+ for path in [
+ str(Path(sys.argv[0]).parent) + "/config.json",
+ "./config.json",
+ ]:
+ try:
+ with open(path) as f:
+ s = f.read()
+ except Exception:
+ continue
+ else:
+ with open(sys.argv[1]) as f:
+ s = f.read()
- with open(sys.argv[1]) as f:
- config = Config.model_validate_json(remove_comments(f.read()))
+ config = Config.model_validate_json(remove_comments(s))
world.spawn_resource(config)