os.path: Add expanduser().

pull/26/head
Paul Sokolovsky 2015-05-08 01:01:29 +03:00
rodzic 58e70ec733
commit eb5556d346
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -47,3 +47,13 @@ def isdir(path):
return stat.S_ISDIR(mode)
except OSError:
return False
def expanduser(s):
if s == "~" or s.startswith("~/"):
h = os.getenv("HOME")
return h + s[1:]
if s[0] == "~":
# Sorry folks, follow conventions
return "/home/" + s[1:]
return s