Skip to content

Commit

Permalink
Update public_transport_victoria.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bremor authored Dec 27, 2020
1 parent d9ee1fc commit 7be669e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async def async_route_types(self):

if response is not None and response.status == 200:
response = await response.json()
_LOGGER.debug(response)
route_types = {}
for r in response["route_types"]:
route_types[r["route_type"]] = r["route_type_name"]
Expand All @@ -71,6 +72,7 @@ async def async_routes(self, route_type):

if response is not None and response.status == 200:
response = await response.json()
_LOGGER.debug(response)
routes = {}
for r in response["routes"]:
routes[r["route_id"]] = r["route_name"]
Expand All @@ -88,6 +90,7 @@ async def async_directions(self, route):

if response is not None and response.status == 200:
response = await response.json()
_LOGGER.debug(response)
directions = {}
for r in response["directions"]:
directions[r["direction_id"]] = r["direction_name"]
Expand All @@ -105,6 +108,7 @@ async def async_stops(self, route):

if response is not None and response.status == 200:
response = await response.json()
_LOGGER.debug(response)
stops = {}
for r in response["stops"]:
stops[r["stop_id"]] = r["stop_name"]
Expand All @@ -123,6 +127,7 @@ async def async_update(self):

if response is not None and response.status == 200:
response = await response.json()
_LOGGER.debug(response)
self.departures = []
for r in response["departures"]:
if r["estimated_departure_utc"] is not None:
Expand All @@ -139,10 +144,12 @@ def build_URL(id, api_key, request):
raw = request + 'devid={}'.format(id)
hashed = hmac.new(api_key.encode('utf-8'), raw.encode('utf-8'), sha1)
signature = hashed.hexdigest()
return BASE_URL + raw + '&signature={}'.format(signature)
url = BASE_URL + raw + '&signature={}'.format(signature)
_LOGGER.debug(url)
return url

def convert_utc_to_local(utc):
d = datetime.datetime.strptime(utc, '%Y-%m-%dT%H:%M:%SZ')
d = d.replace(tzinfo=datetime.timezone.utc)
d = d.astimezone()
return d.strftime('%I:%M %p')
return d.strftime('%I:%M %p')

0 comments on commit 7be669e

Please sign in to comment.