From 7d5d54bd29a5537630f8a6b88cace58c8ee55516 Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 1 Jun 2016 11:42:11 -0400 Subject: [PATCH] [formatting] Territories use parent country's template insertion probabilities --- scripts/geodata/address_formatting/formatter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/geodata/address_formatting/formatter.py b/scripts/geodata/address_formatting/formatter.py index 05703124..28bec3a3 100644 --- a/scripts/geodata/address_formatting/formatter.py +++ b/scripts/geodata/address_formatting/formatter.py @@ -195,6 +195,7 @@ class AddressFormatter(object): def load_country_formats(self): config = yaml.load(open(os.path.join(self.formatter_repo_path, 'conf', 'countries', 'worldwide.yaml'))) + self.country_aliases = {} for key in list(config): country = key language = None @@ -207,6 +208,7 @@ class AddressFormatter(object): # Temporary fix for Norway territories (NO unquoted is a boolean) and recursive references if value['use_country'] in (country, False): continue + self.country_aliases[country] = value['use_country'] address_template = config[value['use_country']]['address_template'] if address_template: @@ -548,7 +550,7 @@ class AddressFormatter(object): if not template: return None - country = country.lower() + country = self.country_aliases.get(country.upper(), country).lower() cache_keys = []