Make worker.val JSON compatible
This commit is contained in:
parent
dbed1fa677
commit
b8b233f630
|
@ -70,6 +70,7 @@ def worker(lat, lon, distance = 1000, json = False):
|
|||
outtext += ",\n" if (json and not outtext.strip()[-1] == "[") else ""
|
||||
station.distance = station.distance or int(cDistance(station.lat(), station.lon(), lat, lon))
|
||||
outtext += station.json(2, distance = True) if json else station.xml(1, distance = True)
|
||||
outtext += "\n" if not json else ""
|
||||
|
||||
outtext += """
|
||||
]
|
||||
|
|
|
@ -22,14 +22,20 @@ def validateName(name):
|
|||
yield Station(name = name, sttype = sttype, extid = extid, xcoord = xcoord, ycoord = ycoord, prodclass = prodclass)
|
||||
|
||||
def worker(name, json = False):
|
||||
outtext = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
outtext = """{
|
||||
"stations": [
|
||||
""" if json else """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stations>
|
||||
"""
|
||||
|
||||
for station in validateName(name):
|
||||
outtext += station.xml(1)
|
||||
outtext += ",\n" if (json and not outtext.strip()[-1] == "[") else ""
|
||||
outtext += station.json(2) if json else station.xml(1)
|
||||
outtext += "\n" if not json else ""
|
||||
|
||||
outtext += "</stations>"
|
||||
outtext += """
|
||||
]
|
||||
}""" if json else "</stations>"
|
||||
|
||||
return outtext
|
||||
|
||||
|
|
Loading…
Reference in a new issue