# SPDX-License-Identifier: MIT """Where the romsets are: environment variables, never a machine path. The family's rule (emulator-lineage methodology, "Provenance in practice"): ROM, BIOS and MAME set locations come from the environment. - ``NO_INTRO_DIR``: the No-Intro tree. The 7800 sets are the folders ``Atari - Atari 7800 (BIN)``, ``... (BIN) (Aftermarket)``, ``... (BIN) (Private)``; 2600 mode's dumps are ``Atari - Atari 2600``. - ``MAME_ROMPATH``: MAME's non-merged sets; the BIOS images are in ``a7800.zip`` (NTSC) and ``a7800p.zip`` (PAL). - ``RETROBAT_DIR`` (optional, only for the census scripts): a curated set whose ``atari7800`` folder holds ``.7z`` copies; left out of the census when unset. Scripts call these and stop with a message naming the variable when it is unset; the library's BIOS search (:func:`a7800_python.system.find_bios`) treats an unset ``MAME_ROMPATH`` as "no BIOS here"; the test fixtures skip, naming the variable. """ from __future__ import annotations import os from pathlib import Path LICENSED_7800 = "Atari - Atari 7800 (BIN)" AFTERMARKET_7800 = "Atari - Atari 7800 (BIN) (Aftermarket)" PRIVATE_7800 = "Atari - Atari 7800 (BIN) (Private)" DUMPS_2600 = "Atari - Atari 2600" class RomsetUnset(RuntimeError): """A romset variable is not set in the environment.""" def env_dir(name: str, what: str) -> Path: """The folder named by environment variable ``name``; raise naming it when unset.""" value = os.environ.get(name, "") if not value: raise RomsetUnset(f"{name} is not set: export it as the folder that holds {what}") return Path(value) def no_intro(folder: str = "") -> Path: """``$NO_INTRO_DIR/``.""" return env_dir("NO_INTRO_DIR", "the No-Intro sets") / folder def mame_rompath() -> Path: """``$MAME_ROMPATH``: MAME's sets (a7800.zip, a7800p.zip).""" return env_dir("MAME_ROMPATH", "MAME's sets (a7800.zip, a7800p.zip)") def retrobat_7800() -> Path | None: """``$RETROBAT_DIR/atari7800``, or None when the optional variable is unset.""" value = os.environ.get("RETROBAT_DIR", "") return Path(value) / "atari7800" if value else None