diff options
author | Ben Connors <benconnors@outlook.com> | 2019-10-26 10:59:14 -0400 |
---|---|---|
committer | Ben Connors <benconnors@outlook.com> | 2019-10-26 10:59:14 -0400 |
commit | 70b62ea7a6be3b3af801f58bc94924074fd5aec2 (patch) | |
tree | ce56092b374d6783112223c8aa8fc76350dc10a1 /interface/input | |
parent | 2cb483c4812eee903295f76f30aaac0b429245d1 (diff) |
More interface features
- Can now edit chasers a bit
o Edit component steps
o Change step durations
Diffstat (limited to 'interface/input')
-rwxr-xr-x | interface/input/parsers.py | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/interface/input/parsers.py b/interface/input/parsers.py index 5e53e03..f97dbf1 100755 --- a/interface/input/parsers.py +++ b/interface/input/parsers.py @@ -73,7 +73,7 @@ def parse_channelrange(s): def parse_value(s): if not s: - return None, s + return None, s, None buff = "" while s: @@ -87,7 +87,7 @@ def parse_value(s): def parse_num(s): if not s: - return None, s + return None, s, None buff = "" while s: @@ -99,6 +99,39 @@ def parse_num(s): return (None if not buff else int(buff)), s, buff +_POSTFIXES = "mcisahkegtp" + +def parse_time(s): + if not s: + return None, s, None + + v, s, d = parse_num(s) + if v is None: + return None, s, None + + if not s: + return v, s, d + + try: + idx = _POSTFIXES.index(s[0].lower()) + except ValueError: + return v, s, d + + v *= 10**idx + return v, s[1:], d+s[0].lower() + +_ALL_LETTERS = "abcdefghijklmnopqrstuvwxyz" +def parse_any_letter(s): + if not s: + return None, s + + l = s[0].lower() + + if l not in _ALL_LETTERS: + return None, s, None + + return _ALL_LETTERS.index(l), s[1:], l + def make_parse_letter(letter, display): def inner(s): if not s or s[0] != letter: @@ -162,4 +195,6 @@ PARSE_MAP = { "$string": parse_string, "$num": parse_num, "$quoted_string": parse_quotedstring, + "$letter": parse_any_letter, + "$time": parse_time, } |