nipoppy.utils.fileops

File operations utility functions.

Module Contents

nipoppy.utils.fileops.copy(source, target, dry_run=False, exist_ok=False)

Copy a file or directory.

Raise an error by default if the target path already exists.

Parameters:
nipoppy.utils.fileops.copy_template(source, dest, *, substitutions, dry_run=False, exist_ok=False)

Copy a file with template substitution.

Parameters:
  • source (pathlib.Path) – Source template file path

  • dest (pathlib.Path) – Destination file path

  • substitutions (dict) – Key-value pairs passed to process_template_str for substitution

  • dry_run (bool)

  • exist_ok (bool)

nipoppy.utils.fileops.mkdir(dpath, dry_run=False)

Create a directory (including parents).

Do nothing if the directory already exists.

Parameters:

dpath (pathlib.Path)

nipoppy.utils.fileops.movetree(source, target, dry_run=False)

Move directory tree.

Parameters:
nipoppy.utils.fileops.rm(path, dry_run=False)

Remove a file, directory, or symlink.

Parameters:

path (pathlib.Path)

Create a symlink: target (symlink) -> source.

Parameters:
nipoppy.utils.fileops.logger