From: Michael Tremer Date: Tue, 30 Jan 2018 16:44:25 +0000 (+0000) Subject: util: Remove any inline comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b653a019c353f4d8574d7e5836e031781ba2c135;p=location%2Flocation-database.git util: Remove any inline comments Signed-off-by: Michael Tremer --- diff --git a/tools/util.py b/tools/util.py index d3a8f24..260b924 100644 --- a/tools/util.py +++ b/tools/util.py @@ -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