]> git.ipfire.org Git - location/location-database.git/commitdiff
util: Remove any inline comments
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 16:44:25 +0000 (16:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 16:44:25 +0000 (16:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tools/util.py

index d3a8f24cc7c3bd7fa577fa9377d341ebb69b65cc..260b9245904cf5a803dd6202afce40b262660110 100644 (file)
@@ -40,6 +40,17 @@ def iterate_over_blocks(f, charsets=("utf-8", "latin1")):
                if line.startswith("#") or line.startswith("%"):
                        continue
 
+               # Remove any comments at the end of line
+               line, hash, comment = line.partition("#")
+
+               if comment:
+                       # Strip any whitespace before the comment
+                       line = line.rstrip()
+
+                       # If the line is now empty, we move on
+                       if not line:
+                               continue
+
                if line:
                        block.append(line)
                        continue