diff options
Diffstat (limited to '')
-rw-r--r-- | quarg/main.py | 15 | ||||
-rw-r--r-- | quarg/utils.py | 15 |
2 files changed, 16 insertions, 14 deletions
diff --git a/quarg/main.py b/quarg/main.py index 2973a2a..541c4d6 100644 --- a/quarg/main.py +++ b/quarg/main.py @@ -5,7 +5,6 @@ import sys from abc import ABCMeta, abstractmethod from timeit import default_timer as timer -import dateutil.parser import dateutil.relativedelta from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker @@ -14,9 +13,7 @@ import quarg.database.filters as filters from quarg.database.tables import Backlog, Buffer, Network, QuasselUser, Sender from quarg.quassel.formatter import format_from from quarg.quassel.types import BufferType, MessageFlag, MessageType - -def errx(msg): - sys.exit(f'quarg: {msg}') +from quarg.utils import errx, parse_isodate # TODO Find out what to do about passing INVALID or GROUP as BufferType # TODO Find out what to do about passing various message flags @@ -51,16 +48,6 @@ class ParseBufferType(ParseEnum): def enumclass(self): return BufferType -def parse_isodate(date): - try: - parsed = dateutil.parser.isoparse(date) - except ValueError as err: - errx(f'isoparse: invalid date format \'{date}\', {err}') - except OverflowError as err: - errx(f'isoparse: date overflows: \'{date}\'') - - return parsed - # FIXME make sure pylint disables are actually still needed everywhere class ParseDate(argparse.Action): diff --git a/quarg/utils.py b/quarg/utils.py new file mode 100644 index 0000000..7fa270e --- /dev/null +++ b/quarg/utils.py @@ -0,0 +1,15 @@ +import sys +import dateutil.parser + +def errx(msg): + sys.exit(f'quarg: {msg}') + +def parse_isodate(date): + try: + parsed = dateutil.parser.isoparse(date) + except ValueError as err: + errx(f'isoparse: invalid date format \'{date}\', {err}') + except OverflowError as err: + errx(f'isoparse: date overflows: \'{date}\'') + + return parsed |