]> git.ipfire.org Git - location/location-database.git/commitdiff
tools: Skip the version line and others
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Jan 2020 17:29:18 +0000 (17:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Jan 2020 17:29:18 +0000 (17:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tools/base.py

index f469bc8ed50ddd924e5cafc79c8757f8ada403de..676f3c1048957ee3f4d7951e1199c6a349347705 100644 (file)
@@ -216,18 +216,26 @@ class RIRParser(object):
 
        def parse_url(self, url):
                with self.downloader.request(url) as r:
-                       for line in r:
+                       for i, line in enumerate(r):
+                               # Skip the first line
+                               if i == 0:
+                                       continue
+
                                self.parse_line(line)
 
        def parse_line(self, line):
+               # Skip comments
+               if line.startswith("#"):
+                       return
+
                try:
                        lacnic, country_code, type, line = line.split("|", 3)
                except:
                        logging.warning("Could not parse line: %s" % line)
                        return
 
-               # Skip any lines with addresses that are not allocated
-               if not "|allocated|" in line and not "|assigned|" in line:
+               # Skip any lines that are for stats only
+               if country_code == "*":
                        return
 
                if type in ("ipv6", "ipv4"):