From: Michael Tremer Date: Tue, 7 Jan 2020 17:29:18 +0000 (+0000) Subject: tools: Skip the version line and others X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b977a15f5f7b6645617fe53046be01cc6ac36690;p=location%2Flocation-database.git tools: Skip the version line and others Signed-off-by: Michael Tremer --- diff --git a/tools/base.py b/tools/base.py index f469bc8..676f3c1 100644 --- a/tools/base.py +++ b/tools/base.py @@ -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"):