Skip to content

Commit

Permalink
Handle feeds with only one of calendar.txt and calendar_dates.txt
Browse files Browse the repository at this point in the history
This bug was introduced in #27 and released in v0.6.0.
  • Loading branch information
invisiblefunnel committed Feb 24, 2018
1 parent b314a41 commit e55cafb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions partridge/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ def _service_ids_by_date(feed):
removals = defaultdict(set)

service_ids = set(feed.trips.service_id)
calendar = feed.calendar
caldates = feed.calendar_dates

# Only consider calendar.txt/calendar_dates.txt rows with applicable trips
calendar = feed.calendar[feed.calendar.service_id.isin(service_ids)].copy()
caldates = feed.calendar_dates[feed.calendar_dates.service_id.isin(service_ids)].copy() # noqa E501
if not calendar.empty:
# Only consider calendar.txt rows with applicable trips
calendar = calendar[calendar.service_id.isin(service_ids)].copy()

if not caldates.empty:
# Only consider calendar_dates.txt rows with applicable trips
caldates = caldates[caldates.service_id.isin(service_ids)].copy()

if not calendar.empty:
# Parse dates
Expand Down

0 comments on commit e55cafb

Please sign in to comment.