#NEWLINE# @ contextmanager #NEWLINE# def from_dir( cwd ) : #NEWLINE# #INDENT# 'Context manager to ensure in the cwd directory.' #NEWLINE# import os #NEWLINE# curdir = os . getcwd ( ) #NEWLINE# try : #NEWLINE# #INDENT# os . chdir ( curdir ) #NEWLINE# ( yield ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# os . chdir ( curdir )