[formatting] Territories use parent country's template insertion probabilities

This commit is contained in:
Al
2016-06-01 11:42:11 -04:00
parent 77a4476b8e
commit 7d5d54bd29

View File

@@ -195,6 +195,7 @@ class AddressFormatter(object):
def load_country_formats(self): def load_country_formats(self):
config = yaml.load(open(os.path.join(self.formatter_repo_path, config = yaml.load(open(os.path.join(self.formatter_repo_path,
'conf', 'countries', 'worldwide.yaml'))) 'conf', 'countries', 'worldwide.yaml')))
self.country_aliases = {}
for key in list(config): for key in list(config):
country = key country = key
language = None language = None
@@ -207,6 +208,7 @@ class AddressFormatter(object):
# Temporary fix for Norway territories (NO unquoted is a boolean) and recursive references # Temporary fix for Norway territories (NO unquoted is a boolean) and recursive references
if value['use_country'] in (country, False): if value['use_country'] in (country, False):
continue continue
self.country_aliases[country] = value['use_country']
address_template = config[value['use_country']]['address_template'] address_template = config[value['use_country']]['address_template']
if address_template: if address_template:
@@ -548,7 +550,7 @@ class AddressFormatter(object):
if not template: if not template:
return None return None
country = country.lower() country = self.country_aliases.get(country.upper(), country).lower()
cache_keys = [] cache_keys = []