diff --git a/feeds/it.json b/feeds/it.json index c62b09ec..d898ae4f 100644 --- a/feeds/it.json +++ b/feeds/it.json @@ -33,7 +33,7 @@ } }, { - "name": "Sardegna-ASPO_Olbia", + "name": "Sardegna-ASPO-Olbia", "type": "http", "url": "https://www.aspo.it/wp-content/uploads/open_data.zip", "license": { @@ -41,12 +41,12 @@ } }, { - "name": "Sardegna-ATP_Nuoro", + "name": "Sardegna-ATP-Nuoro", "type": "transitland-atlas", "transitland-atlas-id": "f-s-atpnuoro" }, { - "name": "Sardegna-ATP_Sassari", + "name": "Sardegna-ATP-Sassari", "type": "transitland-atlas", "transitland-atlas-id": "f-spnp-atpsassari" }, @@ -56,7 +56,7 @@ "transitland-atlas-id": "f-snyr-ctmspa~cagliari" }, { - "name": "Sardegna-Ferries-Collegamenti_marittimi_Corsica", + "name": "Sardegna-Ferries-Collegamenti-marittimi-Corsica", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00010_1_dati_mare_corsica.zip", "license": { @@ -64,7 +64,7 @@ } }, { - "name": "Sardegna-Ferries-Collegamenti_isole_minori", + "name": "Sardegna-Ferries-Collegamenti-isole-minori", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00006_1_dati_mare.zip", "license": { @@ -72,7 +72,7 @@ } }, { - "name": "Sardegna-Ferries-Sardinia_Ferries", + "name": "Sardegna-Ferries-Sardinia-Ferries", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00028_1_dati_sardinia_ferries.zip", "license": { @@ -88,7 +88,7 @@ } }, { - "name": "Sardegna-Planes-Alghero_Airport", + "name": "Sardegna-Planes-Alghero-Airport", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00024_3_GTFS_timetable_winter_it.zip", "license": { @@ -96,7 +96,7 @@ } }, { - "name": "Sardegna-Planes-Cagliari_Airport", + "name": "Sardegna-Planes-Cagliari-Airport", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00030_10_cagliari_timetable.zip", "license": { @@ -104,7 +104,7 @@ } }, { - "name": "Sardegna-Planes-Olbia_Airport", + "name": "Sardegna-Planes-Olbia-Airport", "type": "http", "url": "https://www.sardegnamobilita.it/opendata/R_SARDEGTRASP_00025_10_olbia_timetable.zip", "license": { diff --git a/src/fetch.py b/src/fetch.py index aa4f8273..66e2fba4 100755 --- a/src/fetch.py +++ b/src/fetch.py @@ -17,6 +17,24 @@ import shutil +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + + +def validate_source_name(name: str): + if " " in name: + eprint(f"Error: Feed names must not contain spaces, found {name}.") + sys.exit(1) + + if "_" in name: + eprint(f"Error: Feed names must not contain underscores, found {name}.") + sys.exit(1) + + if "/" in name: + eprint(f"Error: Feed names must not contain slashes, found {name}.") + sys.exit(1) + + class Fetcher: transitland_atlas: transitland.Atlas @@ -142,6 +160,7 @@ def fetch(self, metadata: Path): region_name = metadata_filename[:metadata_filename.rfind('.')] for source in region.sources: + validate_source_name(source.name) download_name = f"{region_name}_{source.name}" print(f"Fetching {region_name}-{source.name}…")