Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_result(place):
address = util.join_filter(
", ",
[place.get('line1'), place.get('line2'),
place.get('line3'), place.get('line4')]
)
city = place.get('city')
state = place.get('state')
country = place.get('country')
location = util.join_filter(", ", [address, city, country])
lat, lng = place.get('latitude'), place.get('longitude')
#if lat and lng:
# point = Point(floatlat, lng)
#else:
# point = None
return (location, (float(lat), float(lng)))
def parse_resource(resource):
stripchars = ", \n"
a = resource['address']
address = a.get('addressLine', '').strip(stripchars)
city = a.get('locality', '').strip(stripchars)
state = a.get('adminDistrict', '').strip(stripchars)
zipcode = a.get('postalCode', '').strip(stripchars)
country = a.get('countryRegion', '').strip(stripchars)
city_state = join_filter(", ", [city, state])
place = join_filter(" ", [city_state, zipcode])
location = join_filter(", ", [address, place, country])
latitude = resource['point']['coordinates'][0] or None
longitude = resource['point']['coordinates'][1] or None
if latitude and longitude:
latitude = float(latitude)
longitude = float(longitude)
return (location, (latitude, longitude))
def parse_resource(resource):
"""
Parse each record.
"""
city = resource['adminArea5']
county = resource['adminArea4']
state = resource['adminArea3']
country = resource['adminArea1']
latLng = resource['latLng']
latitude, longitude = latLng.get('lat'), latLng.get('lng')
location = join_filter(", ", [city, county, state, country])
if latitude and longitude:
latitude = float(latitude)
longitude = float(longitude)
return Location(location, (latitude, longitude), resource)
def parse_result(place):
line1, line2, line3, line4 = place.get('line1'), place.get('line2'), place.get('line3'), place.get('line4')
address = util.join_filter(", ", [line1, line2, line3, line4])
city = place.get('city')
state = place.get('state')
country = place.get('country')
location = util.join_filter(", ", [address, city, country])
lat, lng = place.get('latitude'), place.get('longitude')
#if lat and lng:
# point = Point(floatlat, lng)
#else:
# point = None
return (location, (float(lat), float(lng)))
def _get_address(self, page):
"""
Returns address string from page dictionary
:param page: dict
:return: str
"""
place = page.get('place')
address_city = place.get('city')
address_country_code = place.get('countryCode')
address = join_filter(', ', [address_city, address_country_code])
return address
address = [
place.get('number', None),
place.get('prefix', None),
place.get('street', None),
place.get('type', None),
place.get('suffix', None)
]
city = place.get('city', None)
state = place.get('state', None)
zip_code = place.get('zip', None)
name = util.join_filter(", ", [
util.join_filter(" ", address),
city,
util.join_filter(" ", [state, zip_code])
])
latitude = place.get('lat', None)
longitude = place.get('long', None)
if latitude and longitude:
latlon = float(latitude), float(longitude)
else:
return None
# TODO use Point/Location object API in 0.95
#if latitude and longitude:
# point = Point(latitude, longitude)
#else:
# point = None
#return Location(name, point, dict(result))
return name, latlon
def parse_resource(resource):
"""
Parse each return object.
"""
stripchars = ", \n"
addr = resource['address']
address = addr.get('addressLine', '').strip(stripchars)
city = addr.get('locality', '').strip(stripchars)
state = addr.get('adminDistrict', '').strip(stripchars)
zipcode = addr.get('postalCode', '').strip(stripchars)
country = addr.get('countryRegion', '').strip(stripchars)
city_state = join_filter(", ", [city, state])
place = join_filter(" ", [city_state, zipcode])
location = join_filter(", ", [address, place, country])
latitude = resource['point']['coordinates'][0] or None
longitude = resource['point']['coordinates'][1] or None
if latitude and longitude:
latitude = float(latitude)
longitude = float(longitude)
return Location(location, (latitude, longitude), resource)
address = [
place.get('number', None),
place.get('prefix', None),
place.get('street', None),
place.get('type', None),
place.get('suffix', None)
]
city = place.get('city', None)
state = place.get('state', None)
zip_code = place.get('zip', None)
name = join_filter(", ", [
join_filter(" ", address),
city,
join_filter(" ", [state, zip_code])
])
latitude = place.get('lat', None)
longitude = place.get('long', None)
if latitude and longitude:
latlon = float(latitude), float(longitude)
else:
return None
return Location(name, latlon, place)