From: Michael Tremer Date: Tue, 7 Jan 2020 20:30:27 +0000 (+0000) Subject: tools: Attempt parsing lines without an organisation id X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=376d0a0c0f1b357c153441cca2b7c2748396e823;p=location%2Flocation-database.git tools: Attempt parsing lines without an organisation id Signed-off-by: Michael Tremer --- diff --git a/tools/base.py b/tools/base.py index deb4305..c04a096 100644 --- a/tools/base.py +++ b/tools/base.py @@ -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"):