diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-07-04 07:23:04 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-07-04 07:23:04 +0300 |
| commit | 4bc370b3524c859120172f2e9b9aafbceb8d17d7 (patch) | |
| tree | 0b8b1cc0c6df1b7de884ff881ab4b1837ac0855d /scripts | |
| parent | 4519e7c37c94c5628cd2c65e8c8ab5dc38b61891 (diff) | |
| download | fungus-launcher-4bc370b3524c859120172f2e9b9aafbceb8d17d7.tar.gz fungus-launcher-4bc370b3524c859120172f2e9b9aafbceb8d17d7.tar.xz | |
add a basic failsafe check script for fungus/meson.build
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/check_meson_py_files.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/check_meson_py_files.py b/scripts/check_meson_py_files.py new file mode 100644 index 0000000..06cb834 --- /dev/null +++ b/scripts/check_meson_py_files.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +"""Verify that all .py files in fungus/ are listed in fungus/meson.build.""" + +import re +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +FUNGUS_DIR = ROOT / "fungus" +MESON_BUILD = FUNGUS_DIR / "meson.build" + + +def discover_py_files() -> set[str]: + """Return all .py files directly inside fungus/ (excluding __pycache__).""" + return { + f.name + for f in FUNGUS_DIR.iterdir() + if f.is_file() and f.suffix == ".py" and f.name != "__main__.py" + } + + +def extract_listed_py_files() -> set[str]: + """Parse fungus/meson.build and extract quoted .py filenames.""" + text = MESON_BUILD.read_text(encoding="utf-8") + # Match single-quoted strings ending with .py + return { + m.group(1) + for m in re.finditer(r"'([^']+\.py)'", text) + } + + +def main() -> int: + discovered = discover_py_files() + listed = extract_listed_py_files() + + missing_in_meson = discovered - listed + extra_in_meson = listed - discovered + + status = 0 + if missing_in_meson: + print("❌ .py files in fungus/ NOT listed in meson.build:") + for name in sorted(missing_in_meson): + print(f" {name}") + status = 1 + + if extra_in_meson: + print("⚠️ .py files listed in meson.build but missing from fungus/:") + for name in sorted(extra_in_meson): + print(f" {name}") + if not status: + status = 1 # warn is non-zero too + + if not missing_in_meson and not extra_in_meson: + print("✅ All .py files in fungus/ are accounted for in meson.build.") + + return status + + +if __name__ == "__main__": + sys.exit(main()) |
