aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2019-12-21 21:40:44 +0000
committerGravatar jesopo2019-12-21 21:40:44 +0000
commitb2c5ad041c9c6edeb39acd114f889429b4c32a41 (patch)
treecbb215cca14257c8275ef270718130ade1185892 /src/utils
parentuse utils.parse.format_token_replace() in aliases.py (diff)
signature
simplify token replace, catch one-char end-of-string tokens
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/parse.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/utils/parse.py b/src/utils/parse.py
index 5beb4637..d1b66cf3 100644
--- a/src/utils/parse.py
+++ b/src/utils/parse.py
@@ -129,17 +129,13 @@ def format_tokens(s: str, names: typing.List[str], sigil: str="$"
while i < max:
if s[i] == sigil:
- if s[i+1] == sigil:
+ if not s[i+1] == sigil:
i += 1
- else:
- sigil_found = True
- elif sigil_found:
- sigil_found = False
- for name in names:
- if len(name) <= (len(s)-i) and s[i:i+len(name)] == name:
- tokens.append((i-1, "%s%s" % (sigil, name)))
- i += len(name)
- break
+ for name in names:
+ if len(name) <= (len(s)-i) and s[i:i+len(name)] == name:
+ tokens.append((i-1, "%s%s" % (sigil, name)))
+ i += len(name)
+ break
i += 1
return tokens