isdir() not working properly
sesas opened this issue · 5 comments
>>> root_folder
Path(u'C:\\Users\\Gabriel\\workspace2')
>>> root_folder.isdir()
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
root_folder.isdir()
TypeError: _isdir() takes exactly 1 argument (0 given)
>>>
I have the same "bug".
Under linux my code works like a sharm, but under windows it doesn't work.
I'm using python 2.7.5 and 2.7.5
Linux => Path('.').isdir => <bound method Path.isdir of Path('.')>
Windows => Path('.').isdir => <build-in function _isdir>
I can't understand where is the problem.
I can suggest the following -non very wonderful- fix:
diff --git a/unipath/path.py b/unipath/path.py
index 37d0cb4..25b285a 100644
--- a/unipath/path.py
+++ b/unipath/path.py
@@ -154,7 +154,7 @@ class Path(AbstractPath):
lexists = os.path.lexists
isfile = os.path.isfile
- isdir = os.path.isdir
+ isdir = lambda self: os.path.isdir(self)
islink = os.path.islink
ismount = os.path.ismount
Or, in your own code, you have to write immediately after your first unipath import:
from unipath import Path
Path.isdir = lambda self: os.path.isdir(self)
Note: the issue #5 seems similar, doesn't it?
I thought I made a pull request for this issue. I had it fixed but the owner of the repo did not pull the changes. I actually haven't heard from him for since the start of the summer.
or actually the pull request got clumped into another pull request I had made: #8
I've been wanting to update Unipath but haven't had much time. When I get WebHelpers2 to a release state I'll come back to Unipath. I think for Python 3 compatibility all the functions-as-methods will have to be converted to wrapper methods: apparently the former doesn't work anymore for some reason. I also want to convert the docs to Sphinx, the tests to py.test, and doctests to unit tests. And perhaps the unicode base class stuff can be simplfied.