

def geocode_location(location, sensor=False):
    "Converts a human-readable location to lat-lng.\n\n    Returns a dict with lat and lng keys.\n\n    keyword arguments:\n    location -- A human-readable location, e.g 'London, England'\n    sensor   -- Boolean flag denoting if the location came from a device using\n                its' location sensor (default False)\n\n    raises:\n    GooglePlacesError -- if the geocoder fails to find a location.\n    "
    (url, geo_response) = _fetch_remote_json(GooglePlaces.GEOCODE_API_URL, {
        'address': location,
        'sensor': str(sensor).lower(),
    })
    _validate_response(url, geo_response)
    if (geo_response['status'] == GooglePlaces.RESPONSE_STATUS_ZERO_RESULTS):
        error_detail = ("Lat/Lng for location '%s' can't be determined." % location)
        raise GooglePlacesError(error_detail)
    return geo_response['results'][0]['geometry']['location']

dataset/ETHPy150Open slimkrazy/python-google-places/googleplaces/__init__.py geocode_location/original