Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ config
static/**
templates/**
conf/**
!conf/feed_info.json
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion amarillo/models/gtfs.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
18 changes: 15 additions & 3 deletions amarillo/services/gtfs_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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:
Expand All @@ -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,
Expand Down
Loading