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)
¶
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. |
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
|
Returns:
| Type | Description |
|---|---|
|
None; |
Source code in sleap/io/pathutils.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
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) |
Source code in sleap/io/pathutils.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
list_file_missing(filenames)
¶
Given a list of filenames, returns list of whether file exists.
Source code in sleap/io/pathutils.py
11 12 13 | |