micropython-lib/os.path/os/path.py

38 wiersze
606 B
Python
Czysty Zwykły widok Historia

2014-05-14 14:52:37 +00:00
import os
2014-05-09 20:34:23 +00:00
def normcase(s):
return s
def normpath(s):
return s
def join(*args):
# TODO: this is non-compliant
return "/".join(args)
def split(path):
if path == "":
return ("", "")
r = path.rsplit("/", 1)
if len(r) == 1:
return ("", path)
head = r[0] #.rstrip("/")
if not head:
head = "/"
return (head, r[1])
2014-05-14 14:52:37 +00:00
def exists(path):
return os.access(path, os.F_OK)
# TODO
lexists = exists
2014-05-14 18:16:13 +00:00
def isdir(path):
import stat
try:
mode = os.stat(path)[0]
return stat.S_ISDIR(mode)
except OSError:
return False