def geo_lookup( addr, lang='en' ): ''' geo_lookup( address, language ) -> JSON feedback <type 'dict'> Parameters: addr: address in string lang: (Optional) desired language code in string see http://goo.gl/Xj4Nx for details ''' url = util.norm_url( API_URL + OUTPUT_FORMAT, address=addr, language=lang, sensor=False ) handler = util.open_url(url) return util.get_json(handler)
def find_place( **params ): ''' Stub doc ''' # TODO: validate location and radius types and values url = util.norm_url( API_URL + OUT_FORMAT, ['key', API_KEY], **params ) res = util.open_url(url) j = util.get_json(res) res.close() return j
def reverse_lookup( lat, lng, lang='en' ): ''' reverse_lookup( lat, lng, lang ) -> JSON feedback <type 'dict'> Parameters: lat: latitude in float or str lng: longitude in float or str lang: (Optional) desired language code in string see http://goo.gl/Xj4Nx for details ''' ll = str(lat) + ',' + str(lng) url = util.norm_url( API_URL + OUTPUT_FORMAT, latlng=ll, sensor=False ) handler = util.open_url(url) return util.get_json(handler)
def get_weather(location, locale="en-US"): """ get_weather(Location[,language] ) -> dict input location desired as a string, [ and language (optional),default english] output Weather information,formatted into a dictionary """ url = util.norm_url(API_URL, [], weather=location, hl=locale) res = util.open_url(url) data = res.read() header = res.headers encoding = util.get_encoding(header) res.close() data = util.unicode_s(data, encoding) element = ET.XML(data) return Weather(element)