Skip to content

Commit

Permalink
os.path: Implement isdir().
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalcon committed May 14, 2014
1 parent 780a993 commit c023b96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions os.path/os/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ def exists(path):

# TODO
lexists = exists

def isdir(path):
import stat
try:
mode = os.stat(path)[0]
return stat.S_ISDIR(mode)
except OSError:
return False
7 changes: 7 additions & 0 deletions os.path/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@
assert split("/foo") == ("/", "foo")
assert split("/foo/") == ("/foo", "")
assert split("/foo/bar") == ("/foo", "bar")

assert exists("test_path.py")
assert not exists("test_path.py--")

assert isdir("os")
assert not isdir("os--")
assert not isdir("test_path.py")

0 comments on commit c023b96

Please sign in to comment.