os.path: Add dummy normpath() & join(), working split().

pull/118/head
Paul Sokolovsky 2014-05-14 17:46:23 +03:00
rodzic b5a6cbb4ae
commit 6a89bb6cb6
2 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

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