Make exists support lists. Add a path expander call.

This commit is contained in:
Chris Johns 2013-04-13 10:30:07 +10:00
parent 7e48e8fb57
commit 06dad0acd8

View File

@ -72,8 +72,13 @@ def splitext(path):
root, ext = os.path.splitext(host(path)) root, ext = os.path.splitext(host(path))
return shell(root), ext return shell(root), ext
def exists(path): def exists(paths):
return os.path.exists(host(path)) if type(paths) == list:
results = []
for p in paths:
results += [os.path.exists(host(p))]
return results
return os.path.exists(host(paths))
def isdir(path): def isdir(path):
return os.path.isdir(host(path)) return os.path.isdir(host(path))
@ -116,6 +121,12 @@ def removeall(path):
shutil.rmtree(path, onerror = _onerror) shutil.rmtree(path, onerror = _onerror)
return return
def expand(name, paths):
l = []
for p in paths:
l += [join(p, name)]
return l
if __name__ == '__main__': if __name__ == '__main__':
print host('/a/b/c/d-e-f') print host('/a/b/c/d-e-f')
print host('//a/b//c/d-e-f') print host('//a/b//c/d-e-f')