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
1 changed files with 7 additions and 9 deletions

View File

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