Example #1
0
 def __init__(self, path):
     read_calendars = Reader(path / "calendar.txt")
     self.calendars_list = defaultdict(list)
     line = read_calendars.get_line()
     while line:
         service = Calendar(line)
         service_info = {
             "start": service.start_date,
             "end": service.end_date,
             "id": service.service_id
         }
         if service.mon == "1":
             self.calendars_list["monday"].append(service_info)
         if service.tues == "1":
             self.calendars_list["tuesday"].append(service_info)
         if service.wed == "1":
             self.calendars_list["wednesday"].append(service_info)
         if service.thurs == "1":
             self.calendars_list["thursday"].append(service_info)
         if service.fri == "1":
             self.calendars_list["friday"].append(service_info)
         if service.sat == "1":
             self.calendars_list["saturday"].append(service_info)
         if service.sun == "1":
             self.calendars_list["sunday"].append(service_info)
         line = read_calendars.get_line()
     read_calendars.end()
Example #2
0
 def __init__(self, path):
     read_trips = Reader(path / "trips.txt")
     self.trip_list = []
     line = read_trips.get_line()
     while line:
         self.trip_list.append(Trip(line))
         line = read_trips.get_line()
     read_trips.end()
Example #3
0
 def __init__(self, path, trips):
     read_stop_codes = Reader(path / "stops.txt")
     line = read_stop_codes.get_line()
     self.stop_codes = {}
     while line:
         stop = StopCode(line, trips)
         self.stop_codes[stop.stop_id] = stop
         line = read_stop_codes.get_line()
     read_stop_codes.end()
Example #4
0
 def link_stoptimes(self, path):
     trips = Trips(path)
     self.stops = StopCodes(path, trips)
     read_stoptimes = Reader(path / "stop_times.txt")
     line = read_stoptimes.get_line()
     counter = 0
     while line:
         stop_time = (StopTime(line, trips.trip_list))
         self.stops.add_stop_time(stop_time)
         line = read_stoptimes.get_line()
         counter = counter + 1
         print(str(counter) + " stops parsed.")
     print("Finished parsing stop times...")
     read_stoptimes.end()
Example #5
0
 def __init__(self, path):
     read_calendar_dates = Reader(path / "calendar_dates.txt")
     self.calendar_dates_list = []
     line = read_calendar_dates.get_line()
     while line:
         date_info = CalendarDate(line)
         date_dict = {
             "date": line["date"],
             "service_id": line["service_id"],
             "exception_type": line["exception_type"]
         }
         self.calendar_dates_list.append(date_dict)
         line = read_calendar_dates.get_line()
     read_calendar_dates.end()