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

Proposed by Sylvain Garancher on 2012-07-31
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 2012-07-31 Disapprove on 2012-07-31
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.

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
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 on 2012-07-31

[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
1=== modified file 'example/importcsv.py'
2--- example/importcsv.py 2011-11-14 08:46:43 +0000
3+++ example/importcsv.py 2012-07-31 14:00:35 +0000
4@@ -127,7 +127,7 @@
5 """
6 Read the file, and launched import_data
7 """
8- model = filename.split('/').pop().replace('.csv', '')
9+ model = filename.split('/')[-1].split('\\')[-1].replace('.csv', '')
10 model = model[model.find('-') + 1:]
11 logger.debug('model: %s' % model)
12
13@@ -196,7 +196,7 @@
14 sys.exit(2)
15
16 # recherche du mon de l'objet dans le nom du fichier sans l'extension
17- fn = opts.filename.split('/').pop()
18+ fn = opts.filename.split('/')[-1].split('\\')[-1]
19 if not fn.endswith('.csv'):
20 logger.error('File must have a CSV extension')
21 sys.exit(4)

Subscribers

People subscribed via source and target branches