From 18feca297becbdf93830cb161d88612af4a0dbf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= Date: Fri, 8 Mar 2024 12:32:02 +0100 Subject: [PATCH 1/2] Make it possible to disable feds --- motis/config.ini.j2 | 4 ++-- src/generate-motis-config.py | 6 ++++-- src/metadata.py | 4 ++++ src/transitland.py | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/motis/config.ini.j2 b/motis/config.ini.j2 index 7a61155e..2e965af2 100644 --- a/motis/config.ini.j2 +++ b/motis/config.ini.j2 @@ -22,14 +22,14 @@ host=127.0.0.1 [import] {% if coastline_file and flavour != "import" %}paths=coastline:{{ coastline_file }}{% endif %} {% if pbf_file and flavour != "import" %}paths=osm:{{ pbf_file }}{% endif %} -{% for feed in gtfs_feeds %}paths=schedule-{{ feed.id }}:{{ feed.path }} +{% for feed in gtfs_feeds %}{% if feed.enabled %}paths=schedule-{{ feed.id }}:{{ feed.path }}{% endif %} {% endfor %} [nigiri] first_day=TODAY num_days=365 match_duplicates=true {% if flavour != "import" %} -{% for feed in gtfsrt_feeds %}gtfsrt={{ feed.id }}|{{ feed.url }}{% if feed.authorization %}|{{ feed.authorization }}{% endif %} +{% for feed in gtfsrt_feeds %}{% if feed.enabled %}gtfsrt={{ feed.id }}|{{ feed.url }}{% if feed.authorization %}|{{ feed.authorization }}{% endif %}{% endif %} {% endfor %} {% endif %} [intermodal] diff --git a/src/generate-motis-config.py b/src/generate-motis-config.py index 003a9f92..d869f4a4 100755 --- a/src/generate-motis-config.py +++ b/src/generate-motis-config.py @@ -54,7 +54,8 @@ gtfs_feeds.append({ "id": schedule_name, - "path": schedule_file + "path": schedule_file, + "enabled": source.enabled }) case "gtfs-rt" if isinstance(source, metadata.UrlSource): referenced_static_feed = list(filter( @@ -71,7 +72,8 @@ gtfsrt_feeds.append({ "id": schedule_name, "url": source.url, - "authorization": source.authorization + "authorization": source.authorization, + "enabled": source.enabled }) with open("motis/config.ini.j2") as f: diff --git a/src/metadata.py b/src/metadata.py index 541e657b..31297b55 100644 --- a/src/metadata.py +++ b/src/metadata.py @@ -24,10 +24,14 @@ class Source: fix: bool = False license: Optional[License] = None spec: str = "gtfs" + enabled: bool = True def __init__(self, parsed: dict = None): self.license = License() if parsed: + if "enabled" in parsed: + self.enabled = bool(parsed["enabled"]) + if "license" in parsed: if "spdx-identifier" in parsed["license"]: self.license.spdx_identifier = parsed["license"]["spdx-identifier"] diff --git a/src/transitland.py b/src/transitland.py index ed4f3ce0..ee990470 100644 --- a/src/transitland.py +++ b/src/transitland.py @@ -32,11 +32,13 @@ def source_by_id(self, source: TransitlandSource) -> Union[HttpSource, UrlSource result.url = feed["urls"]["static_current"] result.options = source.options result.spec = "gtfs" + result.enabled = source.enabled elif "realtime_trip_updates" in feed["urls"]: result = UrlSource() result.name = source.name result.url = feed["urls"]["realtime_trip_updates"] result.spec = "gtfs-rt" + result.enabled = source.enabled else: return None From 3bbfe27a53099dd8d98b685f6fbdd923de881974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= Date: Fri, 8 Mar 2024 12:32:33 +0100 Subject: [PATCH 2/2] temp: Disable ch-opentransportdata feed --- feeds/ch.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feeds/ch.json b/feeds/ch.json index ae1e01fc..bbdac732 100644 --- a/feeds/ch.json +++ b/feeds/ch.json @@ -9,14 +9,16 @@ { "name": "opentransportdataswiss", "type": "transitland-atlas", - "transitland-atlas-id": "f-u0-switzerland" + "transitland-atlas-id": "f-u0-switzerland", + "enabled": false }, { "name": "opentransportdataswiss", "type": "url", "spec": "gtfs-rt", "url": "https://api.opentransportdata.swiss/gtfsrt2020", - "authorization": "57c5dbbbf1fe4d000100001833a821a9de3748e5876bfb6c1efe6973" + "authorization": "57c5dbbbf1fe4d000100001833a821a9de3748e5876bfb6c1efe6973", + "enabled": false } ] }