Skip to content

Commit

Permalink
Code cleaup
Browse files Browse the repository at this point in the history
Version bump
  • Loading branch information
kovacsbalu committed Jun 20, 2017
1 parent ec732be commit d25847f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
14 changes: 6 additions & 8 deletions WazeRouteCalculator/WazeRouteCalculator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
"""Waze route calculator"""

# import json
import logging
import requests
# from time import time


class WRCError(Exception):
Expand Down Expand Up @@ -62,7 +60,7 @@ def address_to_coords(self, address):
lat = response_json['location']['lat']
return {"lon": lon, "lat": lat}

def get_route(self, nPaths=1):
def get_route(self, npaths=1):
"""Get route data from waze"""

routing_req_eu = "row-RoutingManager/routingRequest?"
Expand All @@ -78,7 +76,7 @@ def get_route(self, nPaths=1):
"returnGeometries": "true",
"returnInstructions": "true",
"timeout": 60000,
"nPaths": nPaths,
"nPaths": npaths,
"options": "AVOID_TRAILS:t",
}
response = requests.get(self.WAZE_URL + routing_req, params=url_options)
Expand All @@ -87,7 +85,7 @@ def get_route(self, nPaths=1):
raise WRCError(response_json.get("error"))
if response_json.get("alternatives"):
return [alt['response'] for alt in response_json['alternatives']]
if nPaths > 1:
if npaths > 1:
return [response_json['response']]
return response_json['response']

Expand All @@ -110,10 +108,10 @@ def calc_route_info(self):
self.log.info('Time %.2f minutes, distance %.2f km.', route_time, route_distance)
return route_time, route_distance

def calc_all_routes_info(self, nPaths=3):
"""Calculate best route info."""
def calc_all_routes_info(self, npaths=3):
"""Calculate all route infos."""

routes = self.get_route(nPaths)
routes = self.get_route(npaths)
results = {route['routeName']: self._add_up_route(route['results']) for route in routes}
route_time = [route[0] for route in results.values()]
route_distance = [route[1] for route in results.values()]
Expand Down
2 changes: 1 addition & 1 deletion WazeRouteCalculator/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3"
__version__ = "0.4"
1 change: 0 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import WazeRouteCalculator as wrc
import mock
import requests_mock
# import StringIO


class TestWRC():
Expand Down

0 comments on commit d25847f

Please sign in to comment.