From b653a019c353f4d8574d7e5836e031781ba2c135 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 30 Jan 2018 16:44:25 +0000 Subject: [PATCH] util: Remove any inline comments Signed-off-by: Michael Tremer --- tools/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- 2.47.3