Per feed back, kept the stype as date.

Use a tuple to keep as epoch int or process via arrow to timestamp.

I'll look at the test file also.
This commit is contained in:
creslin 2018-06-02 21:59:18 +03:00 committed by creslinux
parent 9dbe5fdb85
commit 43ba02afc6

View File

@ -222,9 +222,9 @@ class Arguments(object):
syntax = [(r'^-(\d{8})$', (None, 'date')), syntax = [(r'^-(\d{8})$', (None, 'date')),
(r'^(\d{8})-$', ('date', None)), (r'^(\d{8})-$', ('date', None)),
(r'^(\d{8})-(\d{8})$', ('date', 'date')), (r'^(\d{8})-(\d{8})$', ('date', 'date')),
(r'^-(\d{10})$', (None, 'timestamp')), (r'^-(\d{10})$', (None, 'date')),
(r'^(\d{10})-$', ('timestamp', None)), (r'^(\d{10})-$', ('date', None)),
(r'^(\d{10})-(\d{10})$', ('timestamp', 'timestamp')), (r'^(\d{10})-(\d{10})$', ('date', 'date')),
(r'^(-\d+)$', (None, 'line')), (r'^(-\d+)$', (None, 'line')),
(r'^(\d+)-$', ('line', None)), (r'^(\d+)-$', ('line', None)),
(r'^(\d+)-(\d+)$', ('index', 'index'))] (r'^(\d+)-(\d+)$', ('index', 'index'))]
@ -239,18 +239,16 @@ class Arguments(object):
if stype[0]: if stype[0]:
start = rvals[index] start = rvals[index]
if stype[0] == 'date': if stype[0] == 'date':
start = arrow.get(start, 'YYYYMMDD').timestamp start = int(start) if len(start) == 10 \
elif stype[0] == 'timestamp': else arrow.get(start, 'YYYYMMDD').timestamp
start = arrow.get(start).timestamp
else: else:
start = int(start) start = int(start)
index += 1 index += 1
if stype[1]: if stype[1]:
stop = rvals[index] stop = rvals[index]
if stype[1] == 'date': if stype[1] == 'date':
stop = arrow.get(stop, 'YYYYMMDD').timestamp stop = int(stop) if len(stop) == 10 \
elif stype[1] == 'timestamp': else arrow.get(stop, 'YYYYMMDD').timestamp
stop = arrow.get(stop).timestamp
else: else:
stop = int(stop) stop = int(stop)
return stype, start, stop return stype, start, stop