Merge lp:~pedro.baeza/banking-addons/7.0-bank-statement-reconcile-prof_parsing into lp:banking-addons/bank-statement-reconcile-70

Proposed by Pedro Manuel Baeza
Status: Superseded
Proposed branch: lp:~pedro.baeza/banking-addons/7.0-bank-statement-reconcile-prof_parsing
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 50 lines (+6/-4)
2 files modified
account_statement_base_import/parser/parser.py (+5/-3)
account_statement_base_import/statement.py (+1/-1)
To merge this branch: bzr merge lp:~pedro.baeza/banking-addons/7.0-bank-statement-reconcile-prof_parsing
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Yannick Vaucher @ Camptocamp Needs Fixing
Review via email: mp+214379@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-09.

Commit message

[IMP] account_statement_base_import: Allow to use profile data for customizing parsing

Description of the change

Simple improvement on the account_statement_base_import module to have profile data on parse method to use it to customize parsing with, for example, a parameter introduced on profiles.

There is no need to do it anything more, because parse method already contains *args and **kwargs. You can access profile data with args[0] in parse method.

To post a comment you must log in.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Next time someone review this module, he will wander why prof is passed to parser and why it is unused.

You should at least add a comment if you don't want it to be removed. Otherwise you should create a hook.

review: Needs Fixing
142. By Pedro Manuel Baeza

[IMP] account_statement_base_import: Comment for prof variable.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Yannick,

I have added a comment to explain the purpose of prof variable.

Thanks for you review.

Regards.

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi,

Why not spend the profile to the parser factory in place of to the parse method?

Regards,

lmi

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I have made it in this way to make little changes, but that can be another solution. What do you prefer?

Regards.

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

I'm a little bit uneasy with the proposed merge since part of the profile information is spend to the parser factory (import_type) and the profile itself to the parse method. We can imagine use cases where information from the profile could be required to initialize the parser. I would prefer to spent the profile object at the earlier to the parser.
It's just my point of view ...

Regards

> I have made it in this way to make little changes, but that can be another
> solution. What do you prefer?
>
> Regards.

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Pedro,

Thanks for the contrib. After thinking about, I must admit I'm in favor of Laurent's suggestion here. Can you make the changes please ?

Regards,

review: Approve (code review, no tests)
143. By Pedro Manuel Baeza

[IMP] account_statement_base_import: Profile passed and stored on parser initialisation instead of an argument for parse method

144. By Pedro Manuel Baeza

Docstring and change in parser factory params

145. By Pedro Manuel Baeza

Change account_statement_transactionid_import and account_statement_ofx_import accordingly.

Unmerged revisions

145. By Pedro Manuel Baeza

Change account_statement_transactionid_import and account_statement_ofx_import accordingly.

144. By Pedro Manuel Baeza

Docstring and change in parser factory params

143. By Pedro Manuel Baeza

[IMP] account_statement_base_import: Profile passed and stored on parser initialisation instead of an argument for parse method

142. By Pedro Manuel Baeza

[IMP] account_statement_base_import: Comment for prof variable.

141. By Pedro Manuel Baeza

[IMP] account_statement_base_import: Allow to use profile data for customizing parsing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_base_import/parser/parser.py'
2--- account_statement_base_import/parser/parser.py 2014-02-28 13:02:35 +0000
3+++ account_statement_base_import/parser/parser.py 2014-05-09 13:46:22 +0000
4@@ -42,7 +42,7 @@
5 from the FileParser instead.
6 """
7
8- def __init__(self, parser_name, *args, **kwargs):
9+ def __init__(self, parser_name, profile, *args, **kwargs):
10 # The name of the parser as it will be called
11 self.parser_name = parser_name
12 # The result as a list of row. One row per line of data in the file, but
13@@ -50,6 +50,8 @@
14 self.result_row_list = None
15 # The file buffer on which to work on
16 self.filebuffer = None
17+ # The profile record to access its parameters in any parser method
18+ self.profile = profile
19 self.balance_start = None
20 self.balance_end = None
21 self.statement_name = None
22@@ -210,7 +212,7 @@
23 yield sub
24
25
26-def new_bank_statement_parser(parser_name, *args, **kwargs):
27+def new_bank_statement_parser(parser_name, profile, *args, **kwargs):
28 """
29 Return an instance of the good parser class base on the providen name
30 :param char: parser_name
31@@ -218,5 +220,5 @@
32 """
33 for cls in itersubclasses(BankStatementImportParser):
34 if cls.parser_for(parser_name):
35- return cls(parser_name, *args, **kwargs)
36+ return cls(parser_name, profile, *args, **kwargs)
37 raise ValueError
38
39=== modified file 'account_statement_base_import/statement.py'
40--- account_statement_base_import/statement.py 2014-05-07 08:50:38 +0000
41+++ account_statement_base_import/statement.py 2014-05-09 13:46:22 +0000
42@@ -156,7 +156,7 @@
43 _("You must provide a valid profile to import a bank statement!"))
44 prof = prof_obj.browse(cr, uid, profile_id, context=context)
45
46- parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
47+ parser = new_bank_statement_parser(prof, ftype=ftype)
48 result_row_list = parser.parse(file_stream)
49 # Check all key are present in account.bank.statement.line!!
50 if not result_row_list:

Subscribers

People subscribed via source and target branches