def from_dir(cwd):
    "Context manager to ensure in the cwd directory."
    import os
    curdir = os.getcwd()
    try:
        os.chdir(cwd)
        yield
    finally:
        os.chdir(curdir)
def from_dir ( cwd ) : import os curdir = os . getcwd ( ) try : os . chdir ( cwd ) yield finally : os . chdir ( curdir )
Context manager to ensure in the cwd directory.