'Decorator to set the working directory around a function'

@classmethod
def in_directory(cls, *directories):

    def decorator(func):
        @wraps(func)
        def inner(*args, **kwargs):
            cls.pushd(*directories)
            try:
                return func(*args, **kwargs)
            finally:
                cls.popd()
        return inner
    return decorator
