From: Peter Müller Date: Wed, 2 Jun 2021 21:00:22 +0000 (+0200) Subject: location-importer.in: track original countries more pythonic X-Git-Tag: 0.9.7~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;ds=sidebyside;h=7434e5e0ca5e6e9ad08d2ab07aa5d45a03bff5b4;p=people%2Fms%2Flibloc.git location-importer.in: track original countries more pythonic https://lists.ipfire.org/pipermail/location/2021-May/000377.html Reported-by: Michael Tremer Signed-off-by: Peter Müller Signed-off-by: Michael Tremer --- diff --git a/src/python/location-importer.in b/src/python/location-importer.in index a3c16bc..3e1f859 100644 --- a/src/python/location-importer.in +++ b/src/python/location-importer.in @@ -628,15 +628,17 @@ class CLI(object): inetnum[key] = [ipaddress.ip_network(val, strict=False)] elif key == "country": + val = val.upper() + # Catch RIR data objects with more than one country code... - if not key in inetnum.keys(): + if not key in inetnum: inetnum[key] = [] else: - if val.upper() in inetnum.get("country"): + if val in inetnum.get("country"): # ... but keep this list distinct... continue - inetnum[key].append(val.upper()) + inetnum[key].append(val) # Skip empty objects if not inetnum or not "country" in inetnum: