diff options
| author | 2019-12-27 13:55:55 +0000 | |
|---|---|---|
| committer | 2019-12-27 13:55:55 +0000 | |
| commit | cff1a55fe6aad8ef6d0aca7c5fd79894bcb9b80b (patch) | |
| tree | e079e1b4410f2eb1f6a4939fd1e5ca41d129c125 /src/utils | |
| parent | `i` should shift righwards also when finding double sigil (diff) | |
| signature | ||
actually replace "$$" with "$"
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/parse.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/parse.py b/src/utils/parse.py index 2680df48..fe26d7aa 100644 --- a/src/utils/parse.py +++ b/src/utils/parse.py @@ -136,11 +136,15 @@ def format_tokens(s: str, names: typing.List[str], sigil: str="$" tokens.append((i-1, "%s%s" % (sigil, name))) i += len(name) break + else: + tokens.append((i, "$")) i += 1 return tokens def format_token_replace(s: str, vars: typing.Dict[str, str], sigil: str="$") -> str: + vars = vars.copy() + vars.update({"": ""}) tokens = format_tokens(s, list(vars.keys()), sigil) tokens.sort(key=lambda x: x[0]) tokens.reverse() |
