Partial commit of more packages.

This commit is contained in:
Todd Gamblin
2014-08-01 08:33:00 -07:00
parent 8738a3a88c
commit c55041e9d4
10 changed files with 210 additions and 36 deletions

View File

@@ -124,8 +124,19 @@ def expand_user(path):
return path.replace('%u', username)
def mkdirp(*paths):
for path in paths:
if not os.path.exists(path):
os.makedirs(path)
elif not os.path.isdir(path):
raise OSError(errno.EEXIST, "File alredy exists", path)
@contextmanager
def working_dir(dirname):
def working_dir(dirname, **kwargs):
if kwargs.get('create', False):
mkdirp(dirname)
orig_dir = os.getcwd()
os.chdir(dirname)
yield
@@ -137,14 +148,6 @@ def touch(path):
os.utime(path, None)
def mkdirp(*paths):
for path in paths:
if not os.path.exists(path):
os.makedirs(path)
elif not os.path.isdir(path):
raise OSError(errno.EEXIST, "File alredy exists", path)
def join_path(prefix, *args):
path = str(prefix)
for elt in args: