Ejemplo n.º 1
0
 def update(self):
     self.tube_status = getJsonFromURL(
         "https://api.tfl.gov.uk/line/mode/tube/status")
     self.dlr_status = getJsonFromURL(
         "https://api.tfl.gov.uk/line/mode/dlr/status")
     self.lines_data = getJsonFromURL(
         "https://api.tfl.gov.uk/line/mode/tube")
     self.updated = datetime.now().strftime("%d-%m-%Y %H:%M")
Ejemplo n.º 2
0
 def getRoutesOnLine(self, line_ID):
     routes = []
     allRoutes = getJsonFromURL("https://api.tfl.gov.uk/line/" + line_ID +
                                "/route")
     for item in allRoutes["routeSections"]:
         routes.append(item["name"].replace('Underground Station', ''))
     return routes
Ejemplo n.º 3
0
 def getStationsOnLine(self, line_ID):
     stations = []
     stations_raw = getJsonFromURL("https://api.tfl.gov.uk/line/" +
                                   line_ID + "/stoppoints")
     for item in stations_raw:
         stations.append(item["commonName"].replace('Underground Station',
                                                    ''))
     return stations
Ejemplo n.º 4
0
 def getRail(self):
     rail_status = getJsonFromURL("https://api.tfl.gov.uk/line/mode/national-rail/status")
     headers = ["Line", "Status", "Issues"]
     data = []
     for item in rail_status:
         if item["lineStatuses"][0]["statusSeverityDescription"] != "Good Service":
             data.append([item["name"], item["lineStatuses"][0]["statusSeverityDescription"]])
         else:
             data.append([item["name"], item["lineStatuses"][0]["statusSeverityDescription"]])
     table = "Last Updated: " + self.updated + "\n" + columnar(data, headers)
     return table
Ejemplo n.º 5
0
 def getAllStations(self, id_select):
     stations_withDuplicates = []
     for item in self.getLines(True):
         stations_raw = getJsonFromURL("https://api.tfl.gov.uk/line/" + item + "/stoppoints")
         for item in stations_raw:
             if id_select:
                 stations_withDuplicates.append(item["id"])
             else:
                 temp = item["commonName"].replace('Underground Station', '')
                 temp = temp.replace('DLR Station', '')
                 stations_withDuplicates.append(temp)
     stations = list(dict.fromkeys(stations_withDuplicates))
     return stations
Ejemplo n.º 6
0
 def getDlrStations(self):
     stations_raw = getJsonFromURL("https://api.tfl.gov.uk/line/dlr/stoppoints")
     stations = []
     for item in stations_raw:
         stations.append(item["commonName"].replace(' DLR Station', ''))
     return stations