[osm] get_first_component for passing in a properties dictionary and returning an address formatting component

This commit is contained in:
Al
2016-07-14 16:57:38 -04:00
parent ad5f34664a
commit f5ecba155f

View File

@@ -66,4 +66,13 @@ class OSMAddressComponents(object):
props = self.config.get(country, {}).get(prop, {})
return props.get(value, None)
def get_first_component(self, country, properties):
for k, v in six.iteritems(props):
containing_component = self.get_component(country, k, v)
break
else:
containing_component = None
return containing_component
osm_address_components = OSMAddressComponents()