aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar jesopo2020-02-19 15:02:12 +0000
committerGravatar jesopo2020-02-19 15:02:12 +0000
commitec54fc8ef017a8f0183c82ad39a1510204a19c55 (patch)
tree3327a220ae35b4292ddc2ae553fbb7ae9ca4ce55 /src
parentfix format_token return typehints (diff)
signature
a comment!
Diffstat (limited to 'src')
-rw-r--r--src/utils/parse/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/utils/parse/__init__.py b/src/utils/parse/__init__.py
index 4fd75e04..28f074c2 100644
--- a/src/utils/parse/__init__.py
+++ b/src/utils/parse/__init__.py
@@ -134,9 +134,12 @@ def format_token_replace(s: str, vars: typing.Dict[str, str],
sigil: str="$") -> str:
vars = vars.copy()
vars.update({sigil: sigil})
+
tokens = format_tokens(s, sigil)
+ # reverse sort tokens so replaces don't effect proceeding indexes
tokens.sort(key=lambda x: x[0])
tokens.reverse()
+
for start, end, token in tokens:
if token in vars:
s = s[:start] + vars[token] + s[end+1:]