Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isdir() not working properly #9

Closed
sesas opened this issue Jun 26, 2013 · 5 comments
Closed

isdir() not working properly #9

sesas opened this issue Jun 26, 2013 · 5 comments

Comments

@sesas
Copy link
Contributor

sesas commented Jun 26, 2013

>>> 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)
>>> 
@dedalus2000
Copy link

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?

@sesas
Copy link
Contributor Author

sesas commented Oct 22, 2013

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

@mikeorr
Copy link
Owner

mikeorr commented Oct 25, 2013

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.

@mikeorr
Copy link
Owner

mikeorr commented Oct 25, 2013

Please also see #11 and add any input you might have.

@mikeorr
Copy link
Owner

mikeorr commented Jan 20, 2015

Fixed in 01118f2.

@mikeorr mikeorr closed this as completed Jan 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants