Skip to content

Commit c023b96

Browse files
committed
os.path: Implement isdir().
1 parent 780a993 commit c023b96

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

os.path/os/path.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ def exists(path):
2727

2828
# TODO
2929
lexists = exists
30+
31+
def isdir(path):
32+
import stat
33+
try:
34+
mode = os.stat(path)[0]
35+
return stat.S_ISDIR(mode)
36+
except OSError:
37+
return False

os.path/test_path.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
assert split("/foo") == ("/", "foo")
77
assert split("/foo/") == ("/foo", "")
88
assert split("/foo/bar") == ("/foo", "bar")
9+
10+
assert exists("test_path.py")
11+
assert not exists("test_path.py--")
12+
13+
assert isdir("os")
14+
assert not isdir("os--")
15+
assert not isdir("test_path.py")

0 commit comments

Comments
 (0)