spansh.py: misc fixes

This commit is contained in:
alterNERDtive 2020-03-09 17:59:35 +01:00
parent 15a8deca65
commit 07a6db2595

View file

@ -41,7 +41,7 @@ def getOldStations():
} }
json = requests.post(APIURLS["stations"], params).json() json = requests.post(APIURLS["stations"], params).json()
ret ="" ret = ""
for station in json["results"]: for station in json["results"]:
if args.short: if args.short:
ret += "{}\n".format(station["system_name"]) ret += "{}\n".format(station["system_name"])
@ -61,7 +61,7 @@ def getOldStationsInSystem(system):
} }
json = requests.post(APIURLS["stations"], params).json() json = requests.post(APIURLS["stations"], params).json()
ret ="" ret = ""
for station in json["results"]: for station in json["results"]:
if args.short: if args.short:
ret += "{}\n".format(station["name"]) ret += "{}\n".format(station["name"])
@ -122,7 +122,7 @@ SORT = {
} }
} }
out ="" out = None
if args.subcommand == "nearestsystem": if args.subcommand == "nearestsystem":
out = getNearestSystem(args.coordinate) out = getNearestSystem(args.coordinate)
elif args.subcommand == "oldstations": elif args.subcommand == "oldstations":
@ -130,12 +130,6 @@ elif args.subcommand == "oldstations":
out = getOldStationsInSystem(args.system) out = getOldStationsInSystem(args.system)
else: else:
out = getOldStations() out = getOldStations()
else:
parser.print_usage(sys.stderr)
sys.exit(1)
if out == "": print(out)
sys.exit(3) sys.exit(0)
else:
print(out)
sys.exit(0)