kopia lustrzana https://github.com/micropython/micropython-lib
os.path: Add dummy normpath() & join(), working split().
rodzic
b5a6cbb4ae
commit
6a89bb6cb6
|
@ -1,2 +1,20 @@
|
|||
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])
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
from os.path import *
|
||||
|
||||
assert split("") == ("", "")
|
||||
assert split("path") == ("", "path")
|
||||
assert split("/") == ("/", "")
|
||||
assert split("/foo") == ("/", "foo")
|
||||
assert split("/foo/") == ("/foo", "")
|
||||
assert split("/foo/bar") == ("/foo", "bar")
|
Ładowanie…
Reference in New Issue