diff options
| author | 2018-10-07 11:24:13 +0100 | |
|---|---|---|
| committer | 2018-10-07 11:24:13 +0100 | |
| commit | 681866339c076fce572e66e756aa6c13078af4cc (patch) | |
| tree | e57587093d505cd71f4cec7e34a65f6f4b5f588e /src | |
| parent | Pass $HOME and $PATH through to scripts in modules/scripts.py (diff) | |
| signature | ||
Support multiple types of comments in utils.get_hashflags
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/__init__.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py index b762e3d2..a700dd95 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -128,15 +128,23 @@ def export(setting, value): return module return _export_func +COMMENT_TYPES = ["#", "//"] def get_hashflags(filename): hashflags = {} with io.open(filename, mode="r", encoding="utf8") as f: for line in f: line = line.strip("\n") - if not line.startswith("#"): + found = False + for comment_type in COMMENT_TYPES: + if line.startswith(comment_type): + line = line.replace(comment_type, "", 1).lstrip() + found = True + break + + if not found: break - elif line.startswith("#--"): - hashflag, sep, value = line[3:].partition(" ") + elif line.startswith("--"): + hashflag, sep, value = line[2:].partition(" ") hashflags[hashflag] = value if sep else None return hashflags.items() |
