aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2020-04-08 14:29:52 +0100
committerGravatar jesopo2020-04-08 14:29:52 +0100
commit5df8df83ad523d8814d69cbf688f0b0944a7f38e (patch)
tree952f783b42a5deabea8ae9fdd04aa4d767b50f15 /src/utils
parentremove now-unused vars (diff)
signature
fail an alias when an ${} var isn't found
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/parse/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/utils/parse/__init__.py b/src/utils/parse/__init__.py
index 262edf4a..36da8ffb 100644
--- a/src/utils/parse/__init__.py
+++ b/src/utils/parse/__init__.py
@@ -131,7 +131,7 @@ def format_tokens(s: str, sigil: str="$"
return tokens
def format_token_replace(s: str, vars: typing.Dict[str, str],
- sigil: str="$") -> str:
+ sigil: str="$") -> typing.Tuple[typing.List[str], str]:
vars = vars.copy()
vars.update({sigil: sigil})
@@ -140,7 +140,10 @@ def format_token_replace(s: str, vars: typing.Dict[str, str],
tokens.sort(key=lambda x: x[0])
tokens.reverse()
+ not_found: typing.List[str] = []
for start, end, token in tokens:
if token in vars:
s = s[:start] + vars[token] + s[end+1:]
- return s
+ else:
+ not_found += token
+ return not_found, s