code: def temporary_dir(root_dir=None, cleanup=True, suffix='', permissions=None, prefix=tempfile.template):
    
    path = tempfile.mkdtemp(dir=root_dir, suffix=suffix, prefix=prefix)
  
    try:
      if permissions is not None:
        os.chmod(path, permissions)
      yield path
    finally:
      if cleanup:
        shutil.rmtree(path, ignore_errors=True)
docs: A with-context that creates a temporary directory.
  
      :API: public
  
      You may specify the following keyword args:
      :param string root_dir: The parent directory to create the temporary directory.
      :param bool cleanup: Whether or not to clean up the temporary directory.
      :param int permissions: If provided, sets the directory permissions to this mode.