Merge lp:~elbati/enapps-csv-import-tool/fix_file_to_list_method into lp:~enapps-london-uk/enapps-csv-import-tool/old_trunk

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~elbati/enapps-csv-import-tool/fix_file_to_list_method
Merge into: lp:~enapps-london-uk/enapps-csv-import-tool/old_trunk
Diff against target: 33 lines (+2/-16)
1 file modified
ea_import/ea_import_chain.py (+2/-16)
To merge this branch: bzr merge lp:~elbati/enapps-csv-import-tool/fix_file_to_list_method
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Disapprove
Enapps Ltd OpenERP Partner London UK Pending
Review via email: mp+122890@code.launchpad.net

Description of the change

This fixes bug 999180
replacing the custom procedure used by 'file_to_list' method with python 'csv' reader

To post a comment you must log in.
Revision history for this message
Juan Rial (OpenERP) (jri-openerp) wrote :

Lorenzo: good point, but I'd get rid of file_to_list altogether like in my previously proposed patch; if the method body fits on one line, there's no point in keeping the method around. Although one could also argue your version is more readable..

But anyway, Enapps doesn't accept merge proposals through launchpad. They use LP only to publish their work. Development happens on an internal git repo, and I'd guess the codebase on LP is probably outdated already.

You might want to check out my fully_patched branch of this project. That's one has all my patches, and is still updated whenever I find a new bug (although I'm using it less now, so not finding many bugs anymore). It can be found here: lp:~jri-openerp/enapps-csv-import-tool/fully-patched

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 09/05/2012 06:07 PM, Juan Rial (OpenERP) wrote:
> Lorenzo: good point, but I'd get rid of file_to_list altogether like in my previously proposed patch; if the method body fits on one line, there's no point in keeping the method around. Although one could also argue your version is more readable..
>
> But anyway, Enapps doesn't accept merge proposals through launchpad. They use LP only to publish their work. Development happens on an internal git repo, and I'd guess the codebase on LP is probably outdated already.
>
> You might want to check out my fully_patched branch of this project. That's one has all my patches, and is still updated whenever I find a new bug (although I'm using it less now, so not finding many bugs anymore). It can be found here: lp:~jri-openerp/enapps-csv-import-tool/fully-patched

Hello Juan.
If Enapps doesn't accept merge proposals, wouldn't it be better if we
create new project (with your fully-patched branch) where we can easily
collaborate and handle bugs, etc?

Revision history for this message
Lorenzo Battistini (elbati) wrote :
review: Disapprove

Unmerged revisions

6. By Lorenzo Battistini

[FIX] ea_import
Using csv module instead of custom procedure

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ea_import/ea_import_chain.py'
2--- ea_import/ea_import_chain.py 2012-05-28 12:49:58 +0000
3+++ ea_import/ea_import_chain.py 2012-09-05 14:53:18 +0000
4@@ -23,6 +23,7 @@
5 import base64
6 import datetime
7 from cStringIO import StringIO
8+import csv
9
10
11 class ea_import_chain(osv.osv):
12@@ -94,22 +95,7 @@
13 def file_to_list(self, cr, uid, ids, context={}):
14 result = []
15 for chain in self.browse(cr, uid, ids, context={}):
16- input_file = StringIO(base64.b64decode(chain.input_file))
17- previouse_line = []
18- for string_record in input_file:
19- if not string_record.strip():
20- break
21- next_line = string_record.decode(chain.charset).split(chain.separator)
22- if previouse_line:
23- previouse_line[-1] += next_line[0]
24- next_line = previouse_line + next_line[1:]
25- last_item = next_line[-1].strip()
26- if last_item and (last_item[0] == chain.delimiter or previouse_line) and last_item[-1] != chain.delimiter:
27- previouse_line = next_line
28- continue
29- previouse_line = []
30- delimiter = chain.delimiter and chain.delimiter + "\n\r" or "\n\r"
31- result.append(map(lambda a: a.strip(delimiter), next_line))
32+ result.extend(list(csv.reader(StringIO(base64.b64decode(chain.input_file)), delimiter=str(chain.separator), quotechar=str(chain.delimiter))))
33 return result
34
35

Subscribers

People subscribed via source and target branches