pathutils
sleap.io.pathutils
¶
Utilities for working with file paths.
Functions:
| Name | Description |
|---|---|
filenames_prefix_change |
Finds missing files by changing the initial part of paths. |
find_changed_subpath |
Finds the smallest initial section of path that was changed. |
list_file_missing |
Given a list of filenames, returns list of whether file exists. |
filenames_prefix_change(filenames, old_prefix, new_prefix, missing=None, confirm_callback=None, is_sequence=None, original_filenames=None)
¶
Finds missing files by changing the initial part of paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filenames
|
The list of filenames, needn't all be missing. For image sequences, this contains display paths (first frame). |
required | |
old_prefix
|
Initial part of path to replace. |
required | |
new_prefix
|
Initial part with which to replace it. |
required | |
missing
|
bool
|
List of which files are known to be missing; if not given, then we'll check each file. |
None
|
confirm_callback
|
Optional[Callable]
|
If given, then we'll call this before applying change to confirm that user wants to apply the change. |
None
|
is_sequence
|
Optional[List[bool]]
|
List indicating which entries are image sequences. For sequences, ALL frames must exist at the new location. |
None
|
original_filenames
|
Optional[List]
|
For image sequences, the full list of frame paths. Used for frame verification when auto-applying prefix changes. |
None
|
Returns:
| Type | Description |
|---|---|
|
None; |
Source code in sleap/io/pathutils.py
find_changed_subpath(old_path, new_path)
¶
Finds the smallest initial section of path that was changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_path
|
str
|
Old path |
required |
new_path
|
str
|
New path |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str, str]
|
(initial part of old path), (corresponding replacement in new path) |