MCPcopy Index your code
hub / github.com/googlemaps/google-maps-services-python / components

Function components

googlemaps/convert.py:208–236  ·  view source on GitHub ↗

Converts a dict of components to the format expected by the Google Maps server. For example: c = {"country": "US", "postal_code": "94043"} convert.components(c) # 'country:US|postal_code:94043' :param arg: The component filter. :type arg: dict :rtype: basestring

(arg)

Source from the content-addressed store, hash-verified

206
207
208def components(arg):
209 """Converts a dict of components to the format expected by the Google Maps
210 server.
211
212 For example:
213 c = {"country": "US", "postal_code": "94043"}
214 convert.components(c)
215 # 'country:US|postal_code:94043'
216
217 :param arg: The component filter.
218 :type arg: dict
219
220 :rtype: basestring
221 """
222
223 # Components may have multiple values per type, here we
224 # expand them into individual key/value items, eg:
225 # {"country": ["US", "AU"], "foo": 1} -> "country:AU", "country:US", "foo:1"
226 def expand(arg):
227 for k, v in arg.items():
228 for item in as_list(v):
229 yield "%s:%s" % (k, item)
230
231 if isinstance(arg, dict):
232 return "|".join(sorted(expand(arg)))
233
234 raise TypeError(
235 "Expected a dict for components, "
236 "but got %s" % type(arg).__name__)
237
238
239def bounds(arg):

Callers

nothing calls this directly

Calls 1

expandFunction · 0.85

Tested by

no test coverage detected