protect_from_overwrite

glotaran.plugin_system.io_plugin_utils.protect_from_overwrite(path: str | PathLike[str], *, allow_overwrite: bool = False) None[source]

Raise FileExistsError if files already exists and allow_overwrite isn’t True.

As a side effect this also creates the parent directory of a file if it does not exist.

Parameters:
  • path (str) – Path to a file or folder.

  • allow_overwrite (bool) – Whether or not to allow overwriting existing files, by default False

Raises: