From 151161cab30d197d7f5c43e60fcc9da1d493c1c6 Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 7 Oct 2015 03:45:56 -0400 Subject: [PATCH] [fix] Raising error in geonames output if a country cannot be localized --- scripts/geodata/geonames/create_geonames_tsv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/geodata/geonames/create_geonames_tsv.py b/scripts/geodata/geonames/create_geonames_tsv.py index b47c8657..ee4e3fdf 100644 --- a/scripts/geodata/geonames/create_geonames_tsv.py +++ b/scripts/geodata/geonames/create_geonames_tsv.py @@ -429,7 +429,10 @@ def create_geonames_tsv(db, out_dir=DEFAULT_DATA_DIR): is_orig_name = row[NAME_INDEX] == row[CANONICAL_NAME_INDEX] and row[LANGUAGE_INDEX] == '' # Set the canonical for countries to the local name, see country_official_name in country_names.py - row[CANONICAL_NAME_INDEX] = country_localized_display_name(alpha2_code.lower()) + country_canonical = country_localized_display_name(alpha2_code.lower()) + if not country_canonical or not country_canonical.strip(): + raise ValueError('Could not get local canonical name for country code={}'.format(alpha2_code)) + row[CANONICAL_NAME_INDEX] = country_canonical geonames_id = row[GEONAMES_ID_INDEX]