haldis/app/hlds/definitions.py

25 lines
819 B
Python
Raw Permalink Normal View History

# Import this class to load the standard HLDS definitions
2022-04-19 22:03:00 +02:00
import subprocess
from pathlib import Path
from typing import List
2022-04-19 22:03:00 +02:00
from .models import Location
from .parser import parse_all_directory
2020-02-25 17:51:53 +01:00
__all__ = ["location_definitions", "location_definition_version"]
# pylint: disable=invalid-name
# TODO Use proper way to get resources, see https://stackoverflow.com/a/10935674
ROOT_DIR = Path(__file__).parent.parent.parent
DATA_DIR = ROOT_DIR / "menus"
location_definitions: List[Location] = parse_all_directory(str(DATA_DIR))
location_definitions.sort(key=lambda l: l.name)
2020-02-25 17:51:53 +01:00
2023-04-19 23:48:59 +02:00
try:
proc = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, cwd=str(ROOT_DIR), check=True)
location_definition_version = proc.stdout.decode().strip()
except FileNotFoundError:
location_definition_version = ""