]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
location-importer.in: track original countries more pythonic
authorPeter Müller <peter.mueller@ipfire.org>
Wed, 2 Jun 2021 21:00:22 +0000 (23:00 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Jun 2021 11:29:50 +0000 (11:29 +0000)
https://lists.ipfire.org/pipermail/location/2021-May/000377.html

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-importer.in

index a3c16bc1ff1ef8939de528c35ddb2c9f25d3fb03..3e1f859cb30af6854fe86cc9deb360ad186c005f 100644 (file)
@@ -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: