Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions omgeo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_service_by_name(self, service_name):
m = getattr(m, p)
return m
except Exception as ex:
raise Exception("%s" % (ex))
raise Exception("%s" % ex)

def add_source(self, source):
"""
Expand Down Expand Up @@ -97,7 +97,7 @@ def geocode(self, pq, waterfall=None, force_stats_logging=False):

start_time = time.time()
waterfall = self.waterfall if waterfall is None else waterfall
if type(pq) in (str, unicode):
if type(pq) == str:
pq = PlaceQuery(pq)
processed_pq = copy.copy(pq)

Expand Down
8 changes: 4 additions & 4 deletions omgeo/places.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, left=-180, top=90, right=180, bottom=-90, wkid=4326):
raise ValueError('Left x-coord must be less than right x-coord.')
if bottom > top:
raise ValueError('Bottom y-coord must be less than top y-coord.')
for k in locals().keys():
for k in list(locals()):
if k != 'self': setattr(self, k, locals()[k])

def to_bing_str(self):
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, query='', address='', neighborhood='', city='',
would be returned as "Vereinigte Staaten Von Amerika"
instead of "United States".
"""
for k in locals().keys():
for k in list(locals()):
if k not in ['self', 'kwargs']: setattr(self, k, locals()[k])
if query == '' and address == '' and city == '' and state == '' and postal == '':
raise Exception('Must provide query or one or more of address, city, state, and postal.')
Expand All @@ -142,7 +142,7 @@ def __repr__(self):
return '<%s%s %s>' % (self.query, self.address, self.postal)


class Candidate():
class Candidate:
"""
Class representing a candidate address returned from geocoders.
Accepts arguments defined below, plus informal keyword arguments.
Expand Down Expand Up @@ -186,7 +186,7 @@ def __init__(self, locator='', score=0, match_addr='', x=None, y=None,
return these values.
"""

for k in locals().keys():
for k in list(locals()):
if k not in ['self', 'kwargs']: setattr(self, k, locals()[k])
for k in kwargs:
setattr(self, k, kwargs[k])
Expand Down
2 changes: 1 addition & 1 deletion omgeo/postprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def __init__(self, attr_dupes, attr_sort, ordered_list, return_clean=False):
def process(self, candidates):
def cleanup(str_):
"""Returns string in uppercase and free of commas."""
if type(str_) in [str, unicode]:
if type(str_) == str:
return str_.replace(',', '').upper()
return str_

Expand Down
4 changes: 2 additions & 2 deletions omgeo/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from base import GeocodeService
from omgeo.services.base import GeocodeService
import json
import logging
from omgeo.places import Candidate
Expand All @@ -9,7 +9,7 @@
from omgeo.postprocessors import AttrFilter, AttrExclude, AttrRename, AttrSorter, \
AttrMigrator, UseHighScoreIfAtLeast, GroupBy, ScoreSorter
import time
from urllib import unquote
from urllib.parse import unquote

logger = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions omgeo/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import socket
import time
from traceback import format_exc
from urllib import urlencode
from urllib2 import HTTPError, urlopen, URLError, Request
from urllib.parse import urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError, URLError
from xml.dom import minidom

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -155,7 +156,7 @@ def _get_json_obj(self, endpoint, query):
response = self._get_response(endpoint, query)
content = response.read()
try:
return loads(content)
return loads(content.decode('utf-8'))
except ValueError:
raise Exception('Could not decode content to JSON:\n%s'
% self.__class__.__name__, content)
Expand Down