From: Michael Tremer Date: Tue, 30 Jan 2018 15:47:33 +0000 (+0000) Subject: Skip any blocks where IP addresses could not be parsed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aa906e798c44ab3f1a1e22872db718a1b882b73;p=location%2Flocation-database.git Skip any blocks where IP addresses could not be parsed Signed-off-by: Michael Tremer --- diff --git a/tools/base.py b/tools/base.py index e424a82..f2b4bbe 100644 --- a/tools/base.py +++ b/tools/base.py @@ -254,9 +254,15 @@ class RIRParser(object): return # Convert to IP address - start_address = ipaddress.ip_address(start_address) - end_address = ipaddress.ip_address(end_address) - prefix = 32 + try: + start_address = ipaddress.ip_address(start_address) + end_address = ipaddress.ip_address(end_address) + except ValueError: + logging.warning("Could not parse line: %s" % line) + return + + # Set prefix to default + prefix = 32 # Count number of addresses in this subnet num_addresses = int(end_address) - int(start_address)