This repository was archived by the owner on Jun 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66departures = obersendling .get_departures ()
77
88for departure in departures :
9- print (departure ['product' ] + departure ['label' ] + "\t " + departure ['destination' ] + "\t " + unicode (departure ['departureTimeMinutes' ]))
9+ print (departure ['product' ] + departure ['label' ] + "\t " + departure ['destination' ] + "\t " + str (departure ['departureTimeMinutes' ]))
1010
1111print (get_nearby_stations (48.0933264 , 11.537161699999999 ))
1212
Original file line number Diff line number Diff line change 11# coding=utf-8
22
3- import urllib2
3+ import requests
44import json
55import datetime
66from time import mktime
1414
1515
1616def _perform_api_request (url ):
17- opener = urllib2 .build_opener ()
18- opener .addheaders = [('X-MVG-Authorization-Key' , api_key )]
19- response = opener .open (url )
20- return json .loads (response .read ())
17+ resp = requests .get (url , headers = {'X-MVG-Authorization-Key' : api_key })
18+ return resp .json ()
2119
2220
2321def _convert_time (time ):
@@ -61,7 +59,7 @@ def get_locations(query):
6159 if isinstance (query , int ):
6260 url = query_url + str (query )
6361 else :
64- url = query_url + urllib2 . quote ( query )
62+ url = query_url + query
6563 results = _perform_api_request (url )
6664 return results ["locations" ]
6765
@@ -148,7 +146,7 @@ class Station:
148146 """
149147
150148 def __init__ (self , station ):
151- if isinstance (station , str ) or isinstance ( station , unicode ) :
149+ if isinstance (station , str ):
152150 self .station_id = get_id_for_station (station )
153151 if self .station_id is None :
154152 raise NameError ("No matching station found" )
You can’t perform that action at this time.
0 commit comments