Fix JSON for connections
This commit is contained in:
parent
337fe033c3
commit
269069878f
|
@ -71,7 +71,7 @@ class Connection:
|
||||||
out += self.depst().xml(indent + 2, **stationkwargs) + "\n"
|
out += self.depst().xml(indent + 2, **stationkwargs) + "\n"
|
||||||
out += " " * indent + " </from>\n"
|
out += " " * indent + " </from>\n"
|
||||||
|
|
||||||
if via and self.via != 0:
|
if via and self.via:
|
||||||
out += " " * indent + " <via>\n"
|
out += " " * indent + " <via>\n"
|
||||||
|
|
||||||
for vst in self.via:
|
for vst in self.via:
|
||||||
|
@ -116,7 +116,7 @@ class Connection:
|
||||||
|
|
||||||
return out
|
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 + "{\n"
|
||||||
|
|
||||||
out += (" " * indent + " \"@id\": %i,\n" % cid) if cid is not False else ""
|
out += (" " * indent + " \"@id\": %i,\n" % cid) if cid is not False else ""
|
||||||
|
@ -125,6 +125,15 @@ class Connection:
|
||||||
out += " " * indent + " \"from\":\n"
|
out += " " * indent + " \"from\":\n"
|
||||||
out += self.depst().json(indent + 2, **stationkwargs) + ",\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:
|
if to:
|
||||||
out += " " * indent + " \"to\":\n"
|
out += " " * indent + " \"to\":\n"
|
||||||
out += self.arrst().json(indent + 2, **stationkwargs) + ",\n"
|
out += self.arrst().json(indent + 2, **stationkwargs) + ",\n"
|
||||||
|
|
|
@ -21,7 +21,7 @@ def getTrains(names = None):
|
||||||
|
|
||||||
if not find:
|
if not find:
|
||||||
for cname in names:
|
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
|
find = True
|
||||||
|
|
||||||
if find:
|
if find:
|
||||||
|
|
Loading…
Reference in a new issue