diff options
| author | 2019-11-18 15:56:44 +0000 | |
|---|---|---|
| committer | 2019-11-18 15:57:23 +0000 | |
| commit | 65023dc84b931a7b5f1fbe095e6abd26606118f4 (patch) | |
| tree | aad617dc4d93c685b4477101f6c7676480f2d131 /src/utils | |
| parent | switch some utils.irc functions to use f-strings (diff) | |
| signature | ||
move "+5m" syntax parsing out to utils.parse
Diffstat (limited to 'src/utils')
| -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 + |
