sleap.io.pathutils

Utilities for working with file paths.

sleap.io.pathutils.filenames_prefix_change(filenames, old_prefix, new_prefix, missing: Optional[bool] = None, confirm_callback: Optional[Callable] = None)[source]

Finds missing files by changing the initial part of paths.

Parameters
  • filenames – The list of filenames, needn’t all be missing.

  • old_prefix – Initial part of path to replace.

  • new_prefix – Initial part with which to replace it.

  • missing – List of which files are known to be missing; if not given, then we’ll check each file.

  • confirm_callback – If given, then we’ll call this before applying change to confirm that user wants to apply the change.

Returns

None; filenames (and missing, if given) have new data.

sleap.io.pathutils.find_changed_subpath(old_path: str, new_path: str) Tuple[str, str][source]

Finds the smallest initial section of path that was changed.

Parameters
  • old_path – Old path

  • new_path – New path

Returns

(initial part of old path), (corresponding replacement in new path)

sleap.io.pathutils.list_file_missing(filenames)[source]

Given a list of filenames, returns list of whether file exists.