From ec54fc8ef017a8f0183c82ad39a1510204a19c55 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 19 Feb 2020 15:02:12 +0000 Subject: [PATCH] a comment! --- src/utils/parse/__init__.py | 3 +++ 1 file changed, 3 insertions(+) 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:]