]> git.ipfire.org Git - location/location-database.git/commitdiff
tools: Attempt parsing lines without an organisation id
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Jan 2020 20:30:27 +0000 (20:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Jan 2020 20:30:27 +0000 (20:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tools/base.py

index deb4305d0e5adeafe2a68282cfcb946a3b12f743..c04a09643430e46dccaea5875ebd5cccb70e5d1f 100644 (file)
@@ -175,9 +175,15 @@ class RIRParser(object):
        def _parse_ip_line(self, country_code, type, line):
                try:
                        address, prefix, date, status, org_id = line.split("|")
-               except:
-                       logging.warning("Unhandled line format: %s" % line)
-                       return
+               except ValueError:
+                       org_id = None
+
+                       # Try parsing the line without org_id
+                       try:
+                               address, prefix, date, status = line.split("|")
+                       except ValueError:
+                               logging.warning("Unhandled line format: %s" % line)
+                               return
 
                # Skip anything that isn't properly assigned
                if not status in ("assigned", "allocated"):
@@ -229,9 +235,15 @@ class RIRParser(object):
        def _parse_asn_line(self, country_code, line):
                try:
                        asn, dunno, date, status, org_id = line.split("|")
-               except:
-                       logging.warning("Could not parse line: %s" % line)
-                       return
+               except ValueError:
+                       org_id = None
+
+                       # Try parsing the line without org_id
+                       try:
+                               asn, dunno, date, status = line.split("|")
+                       except ValueError:
+                               logging.warning("Could not parse line: %s" % line)
+                               return
 
                # Skip anything that isn't properly assigned
                if not status in ("assigned", "allocated"):