From deaa6aa9cd9dd922b52854b5dc0757a18450fa0e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 07:33:18 +0200 Subject: [PATCH] =?UTF-8?q?Filter:=20Verweise=20auf=20nicht=20kopierte=20S?= =?UTF-8?q?treckenverl=C3=A4ufe=20leeren=20(OVapi-Fahrpl=C3=A4ne)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sonst bricht pfaedle mit 'no shape with id' ab. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01X48pE4bzjHej8w9HyZXCjb --- tests/test_core.py | 3 +++ trainpulse/prepare.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index c4b071e..d855a07 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -62,6 +62,9 @@ def make_feed(tmp: Path, shapes=True, files=FILES) -> Feed: assert meta["feed_version"] == ("20261017" if files is FILES else "20261020"), meta assert meta["trips"] == 1 and meta["stop_times"] == 3, meta if shapes: + trips = (tmp / "rail" / "trips.txt").read_text() + assert "SH1" not in trips # Verweise auf nicht kopierte shapes werden geleert + (tmp / "rail" / "trips.txt").write_text(trips.replace("812,", "812,SH1")) # wie pfaedle (tmp / "rail" / "shapes.txt").write_text(SHAPE) prepare.pack_shapes(tmp / "rail") assert not (tmp / "rail" / "shapes.txt").exists() diff --git a/trainpulse/prepare.py b/trainpulse/prepare.py index ff5cdc3..e0dfb99 100644 --- a/trainpulse/prepare.py +++ b/trainpulse/prepare.py @@ -137,6 +137,9 @@ def filter_rail(zip_path: Path, out: Path, version: str | None = None) -> dict: h, rd = rows(z, "trips.txt") trips = [r for r in rd if r[h.index("route_id")] in route_ids] + if "shape_id" in h: # shapes.txt kopieren wir nicht (pfaedle rechnet neu) -> Verweise leeren (z. B. OVapi) + for r in trips: + r[h.index("shape_id")] = "" write_csv(out / "trips.txt", h, trips) trip_ids = {r[h.index("trip_id")] for r in trips} service_ids = {r[h.index("service_id")] for r in trips}