check if matched arguments in transactions are not None
This commit is contained in:
parent
a609c372e1
commit
1cd27395de
1 changed files with 13 additions and 5 deletions
|
|
@ -98,18 +98,26 @@ class FrenchTransaction(Transaction):
|
||||||
m = pattern.match(self.raw)
|
m = pattern.match(self.raw)
|
||||||
if m:
|
if m:
|
||||||
args = m.groupdict()
|
args = m.groupdict()
|
||||||
|
|
||||||
|
def inargs(key):
|
||||||
|
"""
|
||||||
|
inner function to check if a key is in args,
|
||||||
|
and is not None.
|
||||||
|
"""
|
||||||
|
return args.get(key, None) is not None
|
||||||
|
|
||||||
self.type = _type
|
self.type = _type
|
||||||
if 'text' in args:
|
if inargs('text'):
|
||||||
self.label = args['text'].strip()
|
self.label = args['text'].strip()
|
||||||
if 'category' in args:
|
if inargs('category'):
|
||||||
self.category = args['category'].strip()
|
self.category = args['category'].strip()
|
||||||
|
|
||||||
# Set date from information in raw label.
|
# Set date from information in raw label.
|
||||||
if 'dd' and 'mm' in args:
|
if inargs('dd') and inargs('mm'):
|
||||||
dd = int(args['dd'])
|
dd = int(args['dd'])
|
||||||
mm = int(args['mm'])
|
mm = int(args['mm'])
|
||||||
|
|
||||||
if 'yy' in args:
|
if inargs('yy'):
|
||||||
yy = int(args['yy'])
|
yy = int(args['yy'])
|
||||||
else:
|
else:
|
||||||
d = datetime.date.today()
|
d = datetime.date.today()
|
||||||
|
|
@ -125,7 +133,7 @@ class FrenchTransaction(Transaction):
|
||||||
if yy < 100:
|
if yy < 100:
|
||||||
yy += 2000
|
yy += 2000
|
||||||
|
|
||||||
if 'HH' in args and 'MM' in args:
|
if inargs('HH') and inargs('MM'):
|
||||||
self.rdate = datetime.datetime(yy, mm, dd, int(args['HH']), int(args['MM']))
|
self.rdate = datetime.datetime(yy, mm, dd, int(args['HH']), int(args['MM']))
|
||||||
else:
|
else:
|
||||||
self.rdate = datetime.date(yy, mm, dd)
|
self.rdate = datetime.date(yy, mm, dd)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue