A decorator to provide the functionality of the
    PreserveWorkingDirectory context manager for functions and methods.

def pcwd(func):
    """A decorator to provide the functionality of the
    PreserveWorkingDirectory context manager for functions and methods."""
    
    @wraps(func)
    def inner(*args, **kw):
        with PreserveWorkingDirectory():
            return func(*args, **kw)
    
    return inner