def in_directory(file_, *components):
target = os.path.join(os.path.dirname(file_), *components)<EOL>def decorate(func):<EOL><INDENT>"""<STR_LIT>"""<EOL>@wraps(func)<EOL>def wrapped(*args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>oldpath = os.environ.get('<STR_LIT>', '<STR_LIT>')<EOL>cwd = os.getcwd()<EOL>os.chdir(target)<EOL>os.environ['<STR_LIT>'] = cwd + oldpath<EOL>try:<EOL><INDENT>return func(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>os.chdir(cwd)<EOL>os.environ['<STR_LIT>'] = oldpath<EOL><DEDENT><DEDENT>return wrapped<EOL><DEDENT>return decorate<EOL>
A decorator to execute a function in a directory relative to the current
file.

__file__ must be passed as first argument to determine the directory to
start with.

For preserving the ability to import aloe_django in child processes,
the original directory is added to PYTHONPATH.