Merge lp:~syleam/openobject-library/fix_dash_split_bug into lp:openobject-library/1.0

Proposed by Sylvain Garancher
Status: Needs review
Proposed branch: lp:~syleam/openobject-library/fix_dash_split_bug
Merge into: lp:openobject-library/1.0
Diff against target: 21 lines (+2/-2)
1 file modified
example/importcsv.py (+2/-2)
To merge this branch: bzr merge lp:~syleam/openobject-library/fix_dash_split_bug
Reviewer Review Type Date Requested Status
Christophe CHAUVET Disapprove
Review via email: mp+117435@code.launchpad.net

Description of the change

Fixes the bug on Windows operating system when splitting a path which contains dashes on importcsv script

To post a comment you must log in.
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

Hi Sylvain

I prefer you use "os.sep" [1] to find the separator from teh operating system

Please fix and resubmit

Regards,

[1] : http://docs.python.org/release/2.6.8/library/os.html?highlight=os#os.sep

review: Disapprove
Revision history for this message
Niels Huylebroeck (red15) wrote :

It's worth checking out this function to see if it can properly handle the splitting of paths as well:

http://docs.python.org/release/2.6.8/library/os.path.html#os.path.split

Mind the caveat that paths ending in '/' (or '\') will not produce a tail return value.

Unmerged revisions

107. By Sylvain Garancher

[FIX] Fixed dash split bug on directories names under Windows operating system

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'example/importcsv.py'
--- example/importcsv.py 2011-11-14 08:46:43 +0000
+++ example/importcsv.py 2012-07-31 14:00:35 +0000
@@ -127,7 +127,7 @@
127 """127 """
128 Read the file, and launched import_data128 Read the file, and launched import_data
129 """129 """
130 model = filename.split('/').pop().replace('.csv', '')130 model = filename.split('/')[-1].split('\\')[-1].replace('.csv', '')
131 model = model[model.find('-') + 1:]131 model = model[model.find('-') + 1:]
132 logger.debug('model: %s' % model)132 logger.debug('model: %s' % model)
133133
@@ -196,7 +196,7 @@
196 sys.exit(2)196 sys.exit(2)
197197
198 # recherche du mon de l'objet dans le nom du fichier sans l'extension198 # recherche du mon de l'objet dans le nom du fichier sans l'extension
199 fn = opts.filename.split('/').pop()199 fn = opts.filename.split('/')[-1].split('\\')[-1]
200 if not fn.endswith('.csv'):200 if not fn.endswith('.csv'):
201 logger.error('File must have a CSV extension')201 logger.error('File must have a CSV extension')
202 sys.exit(4)202 sys.exit(4)

Subscribers

People subscribed via source and target branches