actually replace "$$" with "$"

This commit is contained in:
jesopo 2019-12-27 13:55:55 +00:00
parent f2eba715b4
commit cff1a55fe6

View file

@ -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()