From eb9f726f2655e08afda6d8a831a54cc1bee299f7 Mon Sep 17 00:00:00 2001 From: Martijn van Exel Date: Wed, 19 Nov 2014 11:13:08 -0700 Subject: [PATCH 1/2] p3 compatibility + some formatting + removing unused import --- overpass/api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/overpass/api.py b/overpass/api.py index b305581aa11..fc98bc8be8e 100644 --- a/overpass/api.py +++ b/overpass/api.py @@ -1,7 +1,7 @@ import sys import requests import json -from shapely.geometry import mapping, Point +from shapely.geometry import Point class API(object): @@ -44,7 +44,7 @@ def Get(self, query, asGeoJSON=False): response = json.loads(self._GetFromOverpass( self._ConstructQLQuery(query))) except OverpassException as oe: - print oe + print(oe) sys.exit(1) if "elements" not in response or len(response["elements"]) == 0: @@ -67,7 +67,7 @@ def _ConstructQLQuery(self, userquery): complete_query = self._QUERY_TEMPLATE.format(responseformat=self.responseformat, query=raw_query) if self.debug: - print complete_query + print(complete_query) return complete_query def _GetFromOverpass(self, query): @@ -79,7 +79,7 @@ def _GetFromOverpass(self, query): try: r = requests.get(self.endpoint, params=payload, timeout=self.timeout) except requests.exceptions.Timeout: - raise OverpassException(408, + raise OverpassException(408, 'Query timed out. API instance is set to time out in {timeout} seconds. ' 'Try passing in a higher value when instantiating this API:' 'api = Overpass.API(timeout=60)'.format(timeout=self.timeout)) @@ -110,9 +110,11 @@ def _asGeoJSON(self, elements): print nodes print ways + class OverpassException(Exception): def __init__(self, status_code, message): self.status_code = status_code self.message = message + def __str__(self): - return json.dumps({'status': self.status_code, 'message': self.message}) \ No newline at end of file + return json.dumps({'status': self.status_code, 'message': self.message}) From 8f979f97d6e83c1f54ab9e8c12226f3877069ea2 Mon Sep 17 00:00:00 2001 From: Martijn van Exel Date: Wed, 19 Nov 2014 11:24:19 -0700 Subject: [PATCH 2/2] more print statements to functions --- overpass/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overpass/api.py b/overpass/api.py index fc98bc8be8e..a2f244c7c9a 100644 --- a/overpass/api.py +++ b/overpass/api.py @@ -107,8 +107,8 @@ def _asGeoJSON(self, elements): "tags": elem.get("tags"), "nodes": elem.get("nodes")} for elem in elements if elem["type"] == "way"] - print nodes - print ways + print(nodes) + print(ways) class OverpassException(Exception):