haldis/app/hlds/definitions.py

22 lines
743 B
Python
Raw 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
proc = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, cwd=str(ROOT_DIR), check=True)
2020-06-22 18:43:52 +02:00
location_definition_version = proc.stdout.decode().strip()