From af3ab3194b591c4796357bd2d8115613c1b25bd0 Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 14 Jul 2016 16:57:38 -0400 Subject: [PATCH] [osm] get_first_component for passing in a properties dictionary and returning an address formatting component --- scripts/geodata/osm/components.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/geodata/osm/components.py b/scripts/geodata/osm/components.py index 2993ef7f..7bf46832 100644 --- a/scripts/geodata/osm/components.py +++ b/scripts/geodata/osm/components.py @@ -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()