location-importer.in: track original countries more pythonic

Message ID 5c46c7bb-4c42-4b8f-28b6-948c7f5641e8@ipfire.org
State Accepted
Commit 7434e5e0ca5e6e9ad08d2ab07aa5d45a03bff5b4
Headers
Series location-importer.in: track original countries more pythonic |

Commit Message

Peter Müller June 2, 2021, 9 p.m. UTC
  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>
---
 src/python/location-importer.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Patch

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: