

def parse_json(self, page, exactly_one=True):
    'Parse display name, latitude, and longitude from an JSON response.'
    if (not isinstance(page, basestring)):
        page = decode_page(page)
    resources = json.loads(page)
    if (exactly_one and (len(resources) != 1)):
        from warnings import warn
        warn(("Didn't find exactly one resource!" + ('(Found %d.), use exactly_one=False\n' % len(resources))))

    def parse_resource(resource):
        location = resource['display_name']
        latitude = (resource['lat'] or None)
        longitude = (resource['lon'] or None)
        if (latitude and longitude):
            latitude = float(latitude)
            longitude = float(longitude)
        return (location, (latitude, longitude))
    if exactly_one:
        return parse_resource(resources[0])
    else:
        return [parse_resource(resource) for resource in resources]

dataset/ETHPy150Open sahana/eden/modules/geopy/geocoders/openmapquest.py OpenMapQuest.parse_json/original