diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-15 19:41:32 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-15 19:41:32 +0100 |
| commit | 889e1ccfdd54d3e68982b9c48d0e324750fce002 (patch) | |
| tree | 3bfc92c633785afe57a3e62880882aab85481577 | |
| parent | df5b6209b221ad76023bf339b6cf21589c3a04d5 (diff) | |
Add feeds, remove extension script
| -rw-r--r-- | build-config.json | 10 | ||||
| -rw-r--r-- | vitrasa_extend/extend.py | 69 |
2 files changed, 10 insertions, 69 deletions
diff --git a/build-config.json b/build-config.json index 4199981..7a7a703 100644 --- a/build-config.json +++ b/build-config.json @@ -29,6 +29,16 @@ "feedId": "vitrasa", "type": "gtfs", "source": "./feeds/vitrasa.zip" + }, + { + "feedId": "shuttle", + "type": "gtfs", + "source": "./feeds/shuttle.zip" + }, + { + "feedId": "ourense", + "type": "gtfs", + "source": "./feeds/ourense.zip" } ], "osm": [ diff --git a/vitrasa_extend/extend.py b/vitrasa_extend/extend.py deleted file mode 100644 index 458e306..0000000 --- a/vitrasa_extend/extend.py +++ /dev/null @@ -1,69 +0,0 @@ -# /// script -# requires-python = ">=3.12" -# dependencies = [ -# "requests" -# ] -# /// - -from argparse import ArgumentParser -import csv -import json -import logging -import os -import shutil -import tempfile -import zipfile - - -def get_rows(input_file: str) -> list[dict]: - rows: list[dict] = [] - - with open(input_file, "r", encoding="utf-8") as f: - reader = csv.DictReader(f) - if reader.fieldnames is None: - return [] - reader.fieldnames = [name.strip() for name in reader.fieldnames] - - for row in reader: - rows.append(row) - - return rows - - -if __name__ == "__main__": - parser = ArgumentParser() - parser.add_argument( - "--debug", - help="Enable debug logging", - action="store_true" - ) - - args = parser.parse_args() - - logging.basicConfig( - level=logging.DEBUG if args.debug else logging.INFO, - format="%(asctime)s - %(levelname)s - %(message)s", - ) - - GTFS_TEMPWORKDIR = tempfile.mkdtemp(prefix="vitrasa_extend_") - - # Unzip the GTFS feed - with zipfile.ZipFile("../feeds/vitrasa.zip", "r") as zip_ref: - zip_ref.extractall(GTFS_TEMPWORKDIR) - - CALENDAR_DATES_FILE = os.path.join(GTFS_TEMPWORKDIR, "calendar_dates.txt") - # Open the calendar_dates.txt file, and copy - - # Create a ZIP archive of the output GTFS - with zipfile.ZipFile("../feeds/vitrasa_fixed.zip", "w", zipfile.ZIP_DEFLATED) as zipf: - for root, _, files in os.walk(GTFS_TEMPWORKDIR): - for file in files: - file_path = os.path.join(root, file) - arcname = os.path.relpath(file_path, GTFS_TEMPWORKDIR) - zipf.write(file_path, arcname) - - logging.info( - "GTFS data from feed has been zipped successfully at ../feeds/vitrasa_fixed.zip." - ) - - shutil.rmtree(GTFS_TEMPWORKDIR) |
