From: Michael Tremer Date: Mon, 4 Mar 2024 09:49:43 +0000 (+0000) Subject: importer: Make translating country codes more extensible X-Git-Tag: 0.9.18~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afc966dbbf52e29f3e9a261fa5a4fc696616ab60;p=location%2Flibloc.git importer: Make translating country codes more extensible Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index 18cca65..4a487c9 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -48,6 +48,11 @@ VALID_ASN_RANGES = ( (131072, 4199999999), ) +TRANSLATED_COUNTRIES = { + # When people say UK, they mean GB + "UK" : "GB", +} + IGNORED_COUNTRIES = set(( # Formerly Yugoslavia "YU", @@ -1109,9 +1114,11 @@ class CLI(object): log.debug("Ignoring country code '%s'" % val) continue - # When people set country codes to "UK", they actually mean "GB" - if val == "UK": - val = "GB" + # Translate country codes + try: + val = TRANSLATED_COUNTRIES[val] + except KeyError: + pass inetnum[key].append(val)