code: def set_cwd(fn):
          
          def wrapped(self, *args, **kwargs):
              log.info('Calling function: %s with args=%s', fn, args if args else [])
              cwd = os.getcwd()
              log.info('Saved cwd: %s', cwd)
              os.chdir(self._cwd)
              log.info('Changing working directory to: %s', self._cwd)
              try:
                  return fn(self, *args, **kwargs)
              finally:
                  os.chdir(cwd)
                  log.info('Restored working directory to: %s', cwd)
  
          return wrapped
docs: Decorator to set the specified working directory to execute the function, and then restore the previous cwd.