Wapt version 1.5
I tried using the `setuphelper ensure_dir` in a package, and I encountered a malfunction:
In fact, the command `ensure_dir('C:\Programmes\Ape')` did nothing. I tested it in a Python console with all possible combinations (putting "r" before 'C:\Programmes...', using `Programmes` instead of `Programmes`...), nothing worked.
So, I looked at the function's code and ran some tests directly in Python:
(of course the directory C:\Program Files does not exist)
Code: Select all
>>> ## Test 1 :
>>> d=path.dirname('C:\program rrr')
>>> d
'C:\\'
>>> path.isdir(d)
True
>>> ## Test 2 :
>>> d="C:\Program rrr"
>>> d
'C:\\Program rrr'
>>> path.isdir(d)
False
>>> ##Test 3 :
>>> d="C:\Program Files"
>>> d
'C:\\Program Files'
>>> path.isdir(d)
True
In test 2, we see that if d is declared as a string and the path does not exist, we do indeed get False.
In test 3, we see that, on the other hand, if the path exists when d is declared as a string, we do get a True.
It seems to me, therefore, that in ensure_dir(), rather than using
Code: Select all
d = os.path.dirname(filename)
Code: Select all
d = filename
Code: Select all
d = str(filename)
E. Trezel
