finally fixed line numbers, improved rendering of station monitor

This commit is contained in:
mia 2026-06-10 11:54:02 +02:00
parent 45e177125c
commit dfb2e2716d
2 changed files with 15 additions and 15 deletions

View file

@ -9,6 +9,7 @@ The application will provide routing information and station departures/arrivals
import requests
import json
import re
from datetime import datetime
from prompt_toolkit import Application
from prompt_toolkit.completion import WordCompleter
@ -75,20 +76,13 @@ class HafasClient:
# - Departure/arrival time: departure["stbStop"]["dTimeS"] or ["aTimeS"]
departures.append({
"name": departure.get("dirTxt"),
"line": (
product.get("nameS")
or product.get("number")
or product.get("name")
or product.get("prodCtx", {}).get("line")
or product.get("prodCtx", {}).get("name")
or product.get("prodCtx", {}).get("nameS")
),
"line": re.search(r'#ZB#([^#]+)', departure.get("jid")).group(1).strip(),
"departure_time": self._format_time(stop.get(time_key)),
"departure_time_raw": stop.get(time_key),
"departure_time_real": self._format_time(stop.get(time_key_real)),
"departure_time_real_raw": stop.get(time_key_real),
"jid": departure.get("jid"),
"raw": departure,
# "raw": departure,
})
return departures
@ -114,13 +108,19 @@ class HafasClient:
trip = self.getTrip(departures[0]["jid"])
__import__('pprint').pprint(trip)
def moniterTest(self):
def monitorTest(self):
stationInput = input("Enter Station Name: ")
station = self.getStationNames(stationInput)
print(station)
# departures = self.getArrDep(station[0][1], arrdep="DEP", count=1)
departures = self.arrDepRequest(station[0][1], arrdep="DEP", count=1)
print(departures)
print("\n)------------------\n")
departures = self.getArrDep(station[0][1], arrdep="DEP", count=2)
__import__('pprint').pprint(departures)
print("\n)------------------\n")
arrivals = self.getArrDep(station[0][1], arrdep="ARR", count=2)
__import__('pprint').pprint(arrivals)
#arrivalsRaw = self.arrDepRequest(station[0][1], arrdep="ARR", count=1)
#__import__('pprint').pprint(arrivalsRaw)
# streq = self.stationRequest(station)["svcResL"][0]["res"]["match"]["locL"]
@ -140,4 +140,4 @@ class HafasClient:
if __name__ == '__main__':
client = HafasClient()
# client.runTests()
client.moniterTest()
client.monitorTest()