Skip to content

Commit

Permalink
Tankerkoenig: Added additional check for tankerkoenig ids
Browse files Browse the repository at this point in the history
  • Loading branch information
psilo909 committed Jan 6, 2018
1 parent 0ca0d2d commit 7828ab7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tankerkoenig/__init__.py
Expand Up @@ -121,15 +121,17 @@ def get_petrol_station_prices(self, ids):
json_obj = response.json()
keys = ['e5', 'e10', 'diesel', 'status']
for id in ids:
result_station = dict()
result_station['id'] = id
for key in keys:
if key in json_obj['prices'][id]:
result_station[key] = json_obj['prices'][id][key]
else:
result_station[key] = ""
result_station_prices.append(result_station)

if id in json_obj['prices']:
result_station = dict()
result_station['id'] = id
for key in keys:
if key in json_obj['prices'][id]:
result_station[key] = json_obj['prices'][id][key]
else:
result_station[key] = ""
result_station_prices.append(result_station)
else:
self.logger.error("No result for station with id %s. Check manually!" % id)
return result_station_prices

def _build_url(self, suffix):
Expand Down

0 comments on commit 7828ab7

Please sign in to comment.