From 74ad180b343ff037ea2732fb836f3fdcb8ac42c4 Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 18 May 2016 20:53:53 -0400 Subject: [PATCH] [addresses] Prefer language-namespaced keys if requested --- scripts/geodata/addresses/components.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/geodata/addresses/components.py b/scripts/geodata/addresses/components.py index 3d5c690f..d7d94c7d 100644 --- a/scripts/geodata/addresses/components.py +++ b/scripts/geodata/addresses/components.py @@ -539,12 +539,12 @@ class AddressComponents(object): else: key, raw_key = name_key, raw_name_key - name = component_value.get(key, component_value.get(raw_key)) - - if not name or (component != AddressFormatter.CITY and name == existing_city_name): - name = component_value.get(name_key, component_value.get(raw_name_key)) - - if not name or (component != AddressFormatter.CITY and name == existing_city_name): + for k in (key, name_key, raw_key, raw_name_key): + name = component_value.get(k) + if name and not (name == existing_city_name and component != AddressFormatter.CITY): + break + # if we've checked all keys without finding a valid name, leave this component out + else: continue if (component, name) not in seen: