From aa8137b4a36422078cbb8a6d39fe9c528ca08003 Mon Sep 17 00:00:00 2001 From: Python3pkg Date: Wed, 17 May 2017 23:55:08 -0700 Subject: [PATCH] Convert to python3 --- chicagotransit/cta.py | 10 +++++----- chicagotransit/metra.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chicagotransit/cta.py b/chicagotransit/cta.py index 59fcd79..87b4470 100644 --- a/chicagotransit/cta.py +++ b/chicagotransit/cta.py @@ -31,7 +31,7 @@ def time(self): url = _base_url + 'gettime' result = requests.get(url, params={'key': self.key}) xml = xmltodict.parse(result.text) - if 'tm' in xml['bustime-response'].keys(): + if 'tm' in list(xml['bustime-response'].keys()): time_str = xml['bustime-response']['tm'] return _time_translation(time_str) else: @@ -42,7 +42,7 @@ def bus_by_id(self, vid): url = _base_url + 'getvehicles' result = requests.get(url, params={'key': self.key, 'vid': vid}) xml = xmltodict.parse(result.text) - if 'vehicle' in xml['bustime-response'].keys(): + if 'vehicle' in list(xml['bustime-response'].keys()): v_data = xml['bustime-response']['vehicle'] time = v_data['tmstmp'] latitude = v_data['lat'] @@ -71,7 +71,7 @@ def routes(self, update=False): url = _base_url + 'getroutes' result = requests.get(url, params={'key': self.key}) xml = xmltodict.parse(result.text) - if 'error' in xml['bustime-response'].keys(): + if 'error' in list(xml['bustime-response'].keys()): errors.error_handler(xml['bustime-response']['error']['msg']) self.bus_routes = [] for resp in xml['bustime-response']['route']: @@ -116,7 +116,7 @@ def busses(self, update=False): params = {'key': self.bt.key, 'rt': self.number} result = requests.get(url, params=params) xml = xmltodict.parse(result.text) - if 'vehicle' in xml['bustime-response'].keys(): + if 'vehicle' in list(xml['bustime-response'].keys()): for resp in xml['bustime-response']: vid = resp['vid'] time = resp['tmstmp'] @@ -156,7 +156,7 @@ def stops(self, direction, update=False): xml = xmltodict.parse(result.text) if hasattr(self, 'stop') and not update: return self.stops - elif 'stop' in xml['bustime-response'].keys(): + elif 'stop' in list(xml['bustime-response'].keys()): self.stop = [] for resp in xml['bustime-response']['stop']: id = resp['stpid'] diff --git a/chicagotransit/metra.py b/chicagotransit/metra.py index 22db9ba..34791be 100644 --- a/chicagotransit/metra.py +++ b/chicagotransit/metra.py @@ -22,7 +22,7 @@ def stations(line): req = requests.get(url, params=data) j = json.loads(req.text) stations = [] - for s_order in j['stations'].keys(): + for s_order in list(j['stations'].keys()): name = j['stations'][s_order]['name'] id = j['stations'][s_order]['id'] stations.append(Station(id, name)) @@ -36,7 +36,7 @@ def trains(line, origin, destination): req = requests.get(url, params=data) j = json.loads(req.text) trains = [] - for key in j.keys(): + for key in list(j.keys()): if key[0:5].lower() == 'train': t_dict = j[key] train_num = t_dict['train_num']