Skip to content

Commit

Permalink
Update clean_feed() in GtfsInstance to clean fast travel warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CBROWN-ONS committed Sep 8, 2023
1 parent 4f3c3a6 commit 6acdee9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/transport_performance/gtfs/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
validate_travel_over_multiple_stops,
validate_travel_between_consecutive_stops,
)
from transport_performance.gtfs.cleaners import (
clean_consecutive_stop_fast_travel_warnings,
clean_multiple_stop_fast_travel_warnings,
)
from transport_performance.utils.defence import (
_is_expected_filetype,
_check_namespace_export,
_check_parent_dir_exists,
_bool_defence,
)


Expand Down Expand Up @@ -182,13 +187,24 @@ def print_alerts(self, alert_type="error"):

return None

def clean_feed(self):
"""Attempt to clean feed using `gtfs_kit`."""
def clean_feed(self, fast_travel: bool = True):
"""Attempt to clean feed using `gtfs_kit`.
Parameters
----------
fast_travel: bool, optional
Whether or not to clean warnings related to fast travel.
"""
_bool_defence(fast_travel)
try:
# In cases where shape_id is missing, keyerror is raised.
# https://developers.google.com/transit/gtfs/reference#shapestxt
# shows that shapes.txt is optional file.
self.feed = self.feed.clean()
if fast_travel:
clean_consecutive_stop_fast_travel_warnings(self)
clean_multiple_stop_fast_travel_warnings(self)
except KeyError:
print("KeyError. Feed was not cleaned.")

Expand Down

0 comments on commit 6acdee9

Please sign in to comment.