os.path: Implement isdir().

pull/118/head
Paul Sokolovsky 2014-05-14 21:16:13 +03:00
rodzic 780a993826
commit c023b96f60
2 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -6,3 +6,10 @@ assert split("/") == ("/", "")
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")