Cope with mismatch in folder-/file-name for Sinai wrt beacons

This commit is contained in:
Raffson 2024-08-23 19:09:29 +02:00
parent 1388985048
commit 9b857d7b0e
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -78,12 +78,17 @@ class Beacons:
if theater.terrain.name in cls._by_terrain:
return
beacons_file = BEACONS_RESOURCE_PATH / f"{theater.terrain.name.lower()}.json"
if not beacons_file.exists():
raise RuntimeError(f"Beacon file {beacons_file.resolve()} is missing")
beacons_filename_mapper = {
"sinaimap": "sinai",
}
filename = theater.terrain.name.lower()
filename = beacons_filename_mapper.get(filename, filename)
beacons_path = BEACONS_RESOURCE_PATH / f"{filename}.json"
if not beacons_path.exists():
raise RuntimeError(f"Beacon file {beacons_path.resolve()} is missing")
beacons = {}
for bid, beacon in json.loads(beacons_file.read_text()).items():
for bid, beacon in json.loads(beacons_path.read_text()).items():
beacons[bid] = Beacon(
name=beacon["name"],
callsign=beacon["callsign"],