location-importer.in: track original countries more pythonic
Commit Message
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(-)
@@ -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: