Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 3563540

Browse files
committed
Back and forth. Switched to get_locations() and get_stations(), which now return arrays
1 parent c37a140 commit 3563540

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

mvg/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,25 @@ def get_id_for_station(station_name):
4747
If more than one station match, the first result is given.
4848
None is returned if no match was found.
4949
"""
50-
station = get_station(station_name)
50+
station = get_stations(station_name)[1]
5151
return station['id']
5252

53-
def get_station(station):
54-
if isinstance(station, int):
55-
url = query_url + str(station)
53+
def get_locations(query):
54+
if isinstance(query, int):
55+
url = query_url + str(query)
5656
else:
57-
url = query_url + urllib2.quote(station)
57+
url = query_url + urllib2.quote(query)
5858
results = _perform_api_request(url)
59+
return results["locations"]
5960

60-
for result in results['locations']:
61+
62+
def get_stations(station):
63+
results = get_locations(station)
64+
stations = []
65+
for result in results:
6166
if result['type'] == 'station':
62-
return result
67+
stations.append(result)
68+
return stations
6369

6470
def get_route(from_station_id, to_station_id, time=None, arrival_time=False, max_time_to_start=None, max_time_to_dest=None):
6571
"""

0 commit comments

Comments
 (0)