Improve handling of comments in .sby files
authorClifford Wolf <clifford@clifford.at>
Fri, 19 Jan 2018 13:26:42 +0000 (14:26 +0100)
committerClifford Wolf <clifford@clifford.at>
Fri, 19 Jan 2018 13:26:42 +0000 (14:26 +0100)
sbysrc/sby_core.py

index 9808485b281d9baf61d63abd5b2419a2f37872a4..10b45fd1526c9a5b4a5c1f68871cb56a8e54cc0a 100644 (file)
@@ -188,12 +188,14 @@ class SbyJob:
         with open("%s/config.sby" % workdir, "r") as f:
             for line in f:
                 raw_line = line
-                line = line.strip()
+                if mode in ["options", "engines", "files"]:
+                    line = re.sub(r"\s*(\s#.*)?$", "", line)
+                    if line == "" or line[0] == "#":
+                        continue
+                else:
+                    line = line.rstrip()
                 # print(line)
 
-                if line == "" or line[0] == "#":
-                    continue
-
                 match = re.match(r"^\s*\[(.*)\]\s*$", line)
                 if match:
                     entries = match.group(1).split()