diff options
| author | 2020-02-19 15:02:12 +0000 | |
|---|---|---|
| committer | 2020-02-19 15:02:12 +0000 | |
| commit | ec54fc8ef017a8f0183c82ad39a1510204a19c55 (patch) | |
| tree | 3327a220ae35b4292ddc2ae553fbb7ae9ca4ce55 | |
| parent | fix format_token return typehints (diff) | |
| signature | ||
a comment!
| -rw-r--r-- | src/utils/parse/__init__.py | 3 |
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:] |
