[IMP] account_statement_transactionid_import: Fix PEP8

This commit is contained in:
Pedro M. Baeza
2014-08-04 16:52:37 +02:00
parent 44a59ce588
commit 2ec18f788e
2 changed files with 60 additions and 61 deletions

View File

@@ -22,24 +22,24 @@ from account_statement_base_import.parser.file_parser import FileParser
class TransactionIDFileParser(FileParser):
"""
TransactionID parser that use a define format in csv or xls to import
"""TransactionID parser that use a define format in csv or xls to import
bank statement.
"""
def __init__(self, profile, ftype='csv', extra_fields=None, header=None, **kwargs):
"""
Add transaction_id in header keys
def __init__(self, profile, ftype='csv', extra_fields=None, header=None,
**kwargs):
"""Add transaction_id in header keys
:param char: profile: Reference to the profile
:param char: ftype: extension of the file (could be csv or xls)
:param dict: extra_fields: extra fields to add to the conversion dict. In the format
{fieldname: fieldtype}
:param list: header : specify header fields if the csv file has no header
"""
:param dict: extra_fields: extra fields to add to the conversion \
dict. In the format {fieldname: fieldtype}
:param list: header : specify header fields if the csv file has no \
header
"""
extra_fields = {'transaction_id': unicode}
super(TransactionIDFileParser, self).__init__(profile, extra_fields=extra_fields,
ftype=ftype, header=header, **kwargs)
super(TransactionIDFileParser, self).__init__(
profile, 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']
@@ -47,21 +47,20 @@ class TransactionIDFileParser(FileParser):
@classmethod
def parser_for(cls, parser_name):
"""
Used by the new_bank_statement_parser class factory. Return true if
"""Used by the new_bank_statement_parser class factory. Return true if
the providen name is generic_csvxls_transaction
"""
return parser_name == 'generic_csvxls_transaction'
def get_st_line_vals(self, line, *args, **kwargs):
"""
This method must return a dict of vals that can be passed to create
"""This method must return a dict of vals that can be passed to create
method of statement line in order to record it. It is the responsibility
of every parser to give this dict of vals, so each one can implement his
own way of recording the lines.
:param: line: a dict of vals that represent a line of result_row_list
:return: dict of values to give to the create method of statement line,
it MUST contain at least:
:param: line: a dict of vals that represent a line of \
result_row_\list
:return: dict of values to give to the create method of statement \
line, it MUST contain at least:
{
'name':value,
'date':value,
@@ -70,13 +69,15 @@ class TransactionIDFileParser(FileParser):
'label':value,
'commission_amount':value,
}
In this generic parser, the commission is given for every line, so we store it
for each one.
In this generic parser, the commission is given for every line, so we
store it for each one.
"""
return {'name': line.get('label', line.get('ref', '/')),
'date': line.get('date', datetime.datetime.now().date()),
'amount': line.get('amount', 0.0),
'ref': line.get('transaction_id', '/'),
'label': line.get('label', ''),
'transaction_id': line.get('transaction_id', '/'),
'commission_amount': line.get('commission_amount', 0.0)}
return {
'name': line.get('label', line.get('ref', '/')),
'date': line.get('date', datetime.datetime.now().date()),
'amount': line.get('amount', 0.0),
'ref': line.get('transaction_id', '/'),
'label': line.get('label', ''),
'transaction_id': line.get('transaction_id', '/'),
'commission_amount': line.get('commission_amount', 0.0)
}