From: Michael Tremer Date: Tue, 4 Jul 2023 09:36:50 +0000 (+0000) Subject: importer: Silently ignore any empty country codes in Geofeeds X-Git-Tag: 0.9.17~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e632485c82409266ca6b0526db3ff710d25b44f;p=people%2Fms%2Flibloc.git importer: Silently ignore any empty country codes in Geofeeds Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index 547ff61..4a54aae 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -1319,8 +1319,12 @@ class CLI(object): self.db.execute("DELETE FROM geofeed_networks \ WHERE geofeed_id = %s", geofeed.id) + lineno = 0 + # Read the output line by line for line in f: + lineno += 1 + line = line.decode() # Strip any newline @@ -1357,7 +1361,12 @@ class CLI(object): country = country.strip() # Check the country code - if not location.country_code_is_valid(country): + if not country: + log.debug("Empty country code in Geofeed %s line %s" \ + % (geofeed.url, lineno)) + continue + + elif not location.country_code_is_valid(country): log.warning("Invalid country code in Geofeed %s: %s" \ % (geofeed.url, country)) continue