trips Module

Parses actions into separate trips

class transperth.smart_rider.trips.TripTracer(actions)[source]

Bases: builtins.object

consume_trip(self) → list[source]

Consumes a single trip, bar the first step

determine_path(self, trip:list) → list[source]

Iterates through the steps in the trip, return a list of locations that were visited, in order, during the trip, along with the service used to travel there

determine_price(self, trip)[source]

Determines the total price for the given trip

generate_meta(self, trip:list) → dict[source]

Computes the following;

  • from location (for the trip)
  • to location (for the trip)
  • trip duration
  • wait time between steps. this is zero on single step trips
  • total price for the trip
Returns:metadata for a trip
grab_step(self) → dict[source]
Returns:a dictionary representing the step
trace(self)[source]

Consumes the provided actions, yielding trips consisting of stepss

transperth.smart_rider.trips.determine_breadth(iterable)[source]

Determines the breadth of the addable contents of the iterable

transperth.smart_rider.trips.determine_trips(actions:list) → list[source]

Analysis’s the given actions, and groups them into trips with appropriate metadata

Returns:a list of trips
transperth.smart_rider.trips.determine_wait_time(trip:list) → datetime.timedelta[source]
transperth.smart_rider.trips.timedelta_repr(td:datetime.timedelta) → str[source]
Returns:a human readable representation of the provided timedelta object