Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual("country:US", convert.components(c))
c = {"country": "US", "foo": 1}
self.assertEqual("country:US|foo:1", convert.components(c))
c = {"country": ["US", "AU"], "foo": 1}
self.assertEqual("country:AU|country:US|foo:1", convert.components(c))
with self.assertRaises(TypeError):
convert.components("test")
with self.assertRaises(TypeError):
convert.components(1)
with self.assertRaises(TypeError):
convert.components(("c", "b"))
def test_components(self):
c = {"country": "US"}
self.assertEqual("country:US", convert.components(c))
c = {"country": "US", "foo": 1}
self.assertEqual("country:US|foo:1", convert.components(c))
c = {"country": ["US", "AU"], "foo": 1}
self.assertEqual("country:AU|country:US|foo:1", convert.components(c))
with self.assertRaises(TypeError):
convert.components("test")
with self.assertRaises(TypeError):
convert.components(1)
with self.assertRaises(TypeError):
convert.components(("c", "b"))
def test_components(self):
c = {"country": "US"}
self.assertEqual("country:US", convert.components(c))
c = {"country": "US", "foo": 1}
self.assertEqual("country:US|foo:1", convert.components(c))
c = {"country": ["US", "AU"], "foo": 1}
self.assertEqual("country:AU|country:US|foo:1", convert.components(c))
with self.assertRaises(TypeError):
convert.components("test")
with self.assertRaises(TypeError):
convert.components(1)
with self.assertRaises(TypeError):
convert.components(("c", "b"))
def test_components(self):
c = {"country": "US"}
self.assertEqual("country:US", convert.components(c))
c = {"country": "US", "foo": 1}
self.assertEqual("country:US|foo:1", convert.components(c))
c = {"country": ["US", "AU"], "foo": 1}
self.assertEqual("country:AU|country:US|foo:1", convert.components(c))
with self.assertRaises(TypeError):
convert.components("test")
with self.assertRaises(TypeError):
convert.components(1)
with self.assertRaises(TypeError):
convert.components(("c", "b"))
two-character value.
:type region: string
:param language: The language in which to return results.
:type language: string
:rtype: list of geocoding results.
"""
params = {}
if address:
params["address"] = address
if components:
params["components"] = convert.components(components)
if bounds:
params["bounds"] = convert.bounds(bounds)
if region:
params["region"] = region
if language:
params["language"] = language
return client._request("/maps/api/geocode/json", params).get("results", [])
strict_bounds=False):
params = {'input': input_text}
if offset:
params['offset'] = offset
if location:
params['location'] = convert.latlng(location)
if radius:
params['radius'] = radius
if language:
params['language'] = language
if types:
params['types'] = types
if components:
params['components'] = convert.components(components)
if strict_bounds:
params['strictbounds'] = 'true'
url = '/maps/api/place/%sautocomplete/json' % url_part
result = await client._request(url, params)
return result['predictions']
if session_token:
params["sessiontoken"] = session_token
if offset:
params["offset"] = offset
if location:
params["location"] = convert.latlng(location)
if radius:
params["radius"] = radius
if language:
params["language"] = language
if types:
params["types"] = types
if components:
if len(components) != 1 or list(components.keys())[0] != "country":
raise ValueError("Only country components are supported")
params["components"] = convert.components(components)
if strict_bounds:
params["strictbounds"] = "true"
url = "/maps/api/place/%sautocomplete/json" % url_part
return client._request(url, params).get("predictions", [])