diff options
Diffstat (limited to 'src/utils/parse.py')
| -rw-r--r-- | src/utils/parse.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/parse.py b/src/utils/parse.py index d5018441..ce2ee793 100644 --- a/src/utils/parse.py +++ b/src/utils/parse.py @@ -1,4 +1,5 @@ import decimal, io, typing +from . import datetime, errors COMMENT_TYPES = ["#", "//"] def hashflags(filename: str @@ -109,3 +110,13 @@ def parse_number(s: str) -> str: raise ValueError("Unknown unit '%s' given to parse_number" % unit) return str(number) +def timed_args(args, min_args): + if args and args[0][0] == "+": + if len(args[1:]) < min_args: + raise errors.EventError("Not enough arguments") + time = datetime.from_pretty_time(args[0][1:]) + if time == None: + raise errors.EventError("Invalid timeframe") + return time, args[1:] + return None, args + |
