diff --git a/.gitignore b/.gitignore index 522c337..d250970 100644 --- a/.gitignore +++ b/.gitignore @@ -153,3 +153,4 @@ config static/** templates/** conf/** +!conf/feed_info.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 82132ea..eb932d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ The changelog lists most feature changes between each release. Search GitHub iss ## 1.1.0 (under development) +- feature: `feed_info` information is now configurable via `conf/feed_info.json`. - feature: agency's download urls are now configured via agency conf option `offers_download_url`. This allows adding new agencies providing a standard amarillo download endpoint for syncing via config only. - feature: Addition to the carpool model: `exceptionDates` now allow to provide exceptions to a regular, weekly schedule by specifying added or removed dates (https://github.com/mfdz/amarillo/commit/ab6e715cc6a7e0079e256e6a0735829f637fe763). - feature: support - on a per agency basis - disabling stop snapping/addition (https://github.com/mfdz/amarillo/commit/4a5399f5cea21ec8a463126bf4f901cbbf332547). diff --git a/README.md b/README.md index ec4b250..796bd1d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,20 @@ Permissions work this way - API-Keys for agencies are allowed to POST/PUT/GET/DELETE their own resources and GET some public resources. +## Customising the Feed Info +To provide custom feed_info information, create a json config file `conf/feed_info.json`and specify the following information: + +```json +{ + "feed_id": "mfdz", + "feed_publisher_name": "MITFAHR|DE|ZENTRALE", + "feed_publisher_url": "http://www.mitfahrdezentrale.de/", + "feed_lang": "de", + "feed_contact_email": "info@null.com", + "feed_contact_url": "http://www.mitfahrdezentrale.de/feedback" +} +``` + ## Integrating new carpool agencies To add a new carpool agency, you need to provide agency metadata, which will be used to generated the GTFS agency.txt and an `agencyconf`, which defines how the agency's carpool diff --git a/amarillo/models/gtfs.py b/amarillo/models/gtfs.py index a54c0fe..4ae3a6d 100644 --- a/amarillo/models/gtfs.py +++ b/amarillo/models/gtfs.py @@ -1,7 +1,7 @@ from collections import namedtuple from datetime import timedelta, datetime -GtfsFeedInfo = namedtuple('GtfsFeedInfo', 'feed_id feed_publisher_name feed_publisher_url feed_lang feed_version') +GtfsFeedInfo = namedtuple('GtfsFeedInfo', 'feed_id feed_publisher_name feed_publisher_url feed_lang feed_contact_email feed_contact_url feed_version') GtfsAgency = namedtuple('GtfsAgency', 'agency_id agency_name agency_url agency_timezone agency_lang agency_email') GtfsRoute = namedtuple('GtfsRoute', 'agency_id route_id route_long_name route_type route_url route_short_name route_desc') GtfsStop = namedtuple('GtfsStop', 'stop_id stop_lat stop_lon stop_name') diff --git a/amarillo/services/gtfs_generator.py b/amarillo/services/gtfs_generator.py index 113d5db..d1026e4 100644 --- a/amarillo/services/gtfs_generator.py +++ b/amarillo/services/gtfs_generator.py @@ -3,12 +3,12 @@ from amarillo.services.gtfs import GtfsRtProducer from amarillo.utils.container import container from glob import glob +from datetime import date import json import schedule import threading import time import logging -from datetime import date, timedelta logger = logging.getLogger(__name__) @@ -28,6 +28,10 @@ agency_id = agency.agency_id agencies.append(agency) +# Load FeedInfo +with open('conf/feed_info.json', 'r') as f: + feed_info_template = json.load(f) + def run_schedule(): while 1: try: @@ -45,9 +49,17 @@ def midnight(): def generate_gtfs(): logger.info("Generate GTFS") + feed_info = GtfsFeedInfo( + feed_info_template.get('feed_id',''), + feed_info_template.get('feed_publisher_name',''), + feed_info_template.get('feed_publisher_url',''), + feed_info_template.get('feed_lang',''), + feed_info_template.get('feed_contact_email',''), + feed_info_template.get('feed_contact_url',''), + date.today().isoformat()) + for region in regions.values(): - # TODO make feed producer infos configurable - feed_info = GtfsFeedInfo('mfdz', 'MITFAHR|DE|ZENTRALE', 'http://www.mitfahrdezentrale.de', 'de', 1) + exporter = GtfsExport( agencies, feed_info,