diff --git a/data/processors/areatree/config.areatree b/data/processors/areatree/config.areatree index d8546bbe5..d836db9b8 100644 --- a/data/processors/areatree/config.areatree +++ b/data/processors/areatree/config.areatree @@ -463,7 +463,7 @@ 5142:Parkhaus P1: -5143:Versorgungsstation: 5160:UCN-Testanlage (Container): - :Max-Planck-Institut Garching:mpg[site],mpi # manually added, see NAT merger + :Max-Planck-Institut Garching:mpi,mpg[site] # manually added, see NAT merger :Max-Planck-Institut für Plasmaphysik:ipp[building] :Max-Planck-Institut für Astrophysik:mpa[building] :Max-Planck-Institut für Biochemie:mpb[building] diff --git a/data/processors/areatree/process.py b/data/processors/areatree/process.py index 8daab14b5..f5db28c6c 100644 --- a/data/processors/areatree/process.py +++ b/data/processors/areatree/process.py @@ -90,6 +90,10 @@ def _extract_id_and_type(internal_id: str, b_prefix: str | list[str] | None) -> results: models.IdType = {"id": "", "type": ""} if "[" in internal_id: internal_id, results["type"] = internal_id.removesuffix("]").split("[") + if "," in results["type"]: + raise RuntimeError(f"can't parse {internal_id}." + f"The type has to be specified after specifying visible_ids." + f"try :id,visible_ids[type] instead") if "," in internal_id: ids = internal_id.split(",") if len(ids) != 2: diff --git a/data/processors/areatree/test_areatree.py b/data/processors/areatree/test_areatree.py index b39936d51..9ef3a11d7 100644 --- a/data/processors/areatree/test_areatree.py +++ b/data/processors/areatree/test_areatree.py @@ -82,6 +82,16 @@ def test_specified_type() -> None: assert _extract_id_and_type("abc[building]", "cdf") == expected +def test_comma_specified_type() -> None: + """If the building id is separated by a comma, it is split into a list""" + + expected = {"id": "abc", "type": "building", 'visible_id': 'bcd'} + with pytest.raises(RuntimeError): + assert _extract_id_and_type("abc[building],bcd", None) + assert _extract_id_and_type("abc,bcd[building]", None) == expected + assert _extract_id_and_type("abc,bcd[building]", "cdf") == expected + + def test_comma() -> None: """If the id is inferable from the line, it is returned""" expected = {"id": "123", "visible_id": "visible_id", "type": "area"} diff --git a/data/processors/nat.py b/data/processors/nat.py index 6b7e436df..f9e96e190 100644 --- a/data/processors/nat.py +++ b/data/processors/nat.py @@ -58,6 +58,8 @@ def _infer_internal_id(building, data): if building.b_code.startswith("X"): if building.b_code == "XUCL": building.b_id = "origins-cluster" + elif building.b_code == "XMPG": + building.b_id = "mpi" else: building.b_id = building.b_code[1:].lower()