remove old code & use format

master
Paul Walko 2017-05-29 17:28:14 -04:00
parent d8eefde17e
commit 9e8899bce1
1 changed files with 3 additions and 6 deletions

View File

@ -17,14 +17,11 @@ r_from = re.compile(r'(?i)([+-]\d+):00 from')
def location(q): def location(q):
uri = 'https://nominatim.openstreetmap.org/search?%s={query}&format=json' uri = 'https://nominatim.openstreetmap.org/search?{type}={query}&format=json'
if q.isdigit(): if q.isdigit():
uri = uri % 'postalcode' uri = uri . format(type = 'postalcode', query = web.quote(q))
else: else:
uri = uri % 'q' uri = uri . format(type = 'q', query = web.quote(q))
uri = uri . format(query = web.quote(q))
# uri = 'https://nominatim.openstreetmap.org/search/?q={query}&format=json'.\
# format(query=web.quote(q))
results = web.get(uri) results = web.get(uri)
data = json.loads(results) data = json.loads(results)