kopia lustrzana https://github.com/micropython/micropython-lib
os.path: Implement isdir().
rodzic
780a993826
commit
c023b96f60
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Ładowanie…
Reference in New Issue