diff --git a/classes/connection.py b/classes/connection.py index f147a23..40cd307 100644 --- a/classes/connection.py +++ b/classes/connection.py @@ -71,7 +71,7 @@ class Connection: out += self.depst().xml(indent + 2, **stationkwargs) + "\n" out += " " * indent + " \n" - if via and self.via != 0: + if via and self.via: out += " " * indent + " \n" for vst in self.via: @@ -116,7 +116,7 @@ class Connection: return out - def json(self, indent = 0, cid = False, frm = True, to = True, deptime = True, arrtime = True, duration = True, changes = True, services = True, servicekwargs = {}, stationkwargs = {}): + def json(self, indent = 0, cid = False, frm = True, to = True, deptime = True, arrtime = True, duration = True, changes = True, services = True, via = True, servicekwargs = {}, stationkwargs = {}): out = " " * indent + "{\n" out += (" " * indent + " \"@id\": %i,\n" % cid) if cid is not False else "" @@ -125,6 +125,15 @@ class Connection: out += " " * indent + " \"from\":\n" out += self.depst().json(indent + 2, **stationkwargs) + ",\n" + if via and self.via: + out += " " * indent + " \"via\": [\n" + + for vst in self.via: + out += vst.json(indent + 3, **stationkwargs) + ",\n" + + out = "".join(out.rsplit(",", 1)) + out += " " * indent + " ]\n" + if to: out += " " * indent + " \"to\":\n" out += self.arrst().json(indent + 2, **stationkwargs) + ",\n" diff --git a/workers/radar.py b/workers/radar.py index 1cc34cf..1980ead 100644 --- a/workers/radar.py +++ b/workers/radar.py @@ -21,7 +21,7 @@ def getTrains(names = None): if not find: for cname in names: - if cname.lower().replace(" ", "") == name.split("-")[0].lower().replace(" ", ""): + if cname.lower().replace(" ", "") == name.split("-")[0].lower().replace(" ", "") or name.lower().replace(" ", "").startswith(cname.lower().replace(" ", "")): find = True if find: