[IMP] adapt parser __init__ to new signature

This commit is contained in:
Yannick Vaucher
2013-11-06 16:23:06 +01:00
parent 9596022ce3
commit e9840da124

View File

@@ -27,16 +27,21 @@ class TransactionIDFileParser(FileParser):
bank statement. bank statement.
""" """
def __init__(self, parse_name, ftype='csv'): def __init__(self, parse_name, ftype='csv', extra_fields=None, header=None, **kwargs):
conversion_dict = {'transaction_id': unicode, """
'label': unicode, Add transaction_id in header keys
'date': datetime.datetime, :param char: parse_name: The name of the parser
'amount': float, :param char: ftype: extension of the file (could be csv or xls)
'commission_amount': float} :param dict: extra_fields: extra fields to add to the conversion dict. In the format
# Order of cols does not matter but first row of the file has to be header {fieldname: fieldtype}
keys_to_validate = ['transaction_id', 'label', 'date', 'amount', 'commission_amount'] :param list: header : specify header fields if the csv file has no header
super(TransactionIDFileParser, self).__init__(parse_name, keys_to_validate=keys_to_validate, """
ftype=ftype, conversion_dict=conversion_dict) extra_fields = {'transaction_id': unicode}
super(TransactionIDFileParser, self).__init__(parse_name, extra_fields=extra_fields,
ftype=ftype, header=header, **kwargs)
# ref is replaced by transaction_id thus we delete it from check
self.keys_to_validate = [k for k in self.keys_to_validate if k != 'ref']
del self.conversion_dict['ref']
@classmethod @classmethod
def parser_for(cls, parser_name): def parser_for(cls, parser_name):