path_tools
collect_frames(files)
Returns dict of source path and its frame, if from sequence
Uses clique as most precise solution, used when anatomy template that created files is not known.
Assumption is that frames are separated by '.', negative frames are not allowed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files(list) | or (set with single value | list of source paths | required |
Returns:
Name | Type | Description |
---|---|---|
dict | {'/folder/product_v001.0001.png': '0001', ....} |
Source code in client/ayon_core/lib/path_tools.py
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 72 73 74 75 76 77 78 79 80 |
|
create_hard_link(src_path, dst_path)
Create hardlink of file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_path(str) | Full path to a file which is used as source for hardlink. | required | |
dst_path(str) | Full path to a file where a link of source will be added. | required |
Source code in client/ayon_core/lib/path_tools.py
31 32 33 34 35 36 37 38 39 40 |
|
format_file_size(file_size, suffix=None)
Returns formatted string with size in appropriate unit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_size | int | Size of file in bytes. | required |
suffix | str | Suffix for formatted size. Default is 'B' (as bytes). | None |
Returns:
Name | Type | Description |
---|---|---|
str | Formatted size using proper unit and passed suffix (e.g. 7 MiB). |
Source code in client/ayon_core/lib/path_tools.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
get_last_version_from_path(path_dir, filter)
Find last version of given directory content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_dir | str | directory path | required |
filter | list | list of strings used as file name filter | required |
Returns:
Name | Type | Description |
---|---|---|
str | file name with last version |
Example
last_version_file = get_last_version_from_path( "/project/shots/shot01/work", ["shot01", "compositing", "nk"])
Source code in client/ayon_core/lib/path_tools.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
get_version_from_path(file)
Find version number in file path string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file | str | file path | required |
Returns:
Name | Type | Description |
---|---|---|
str | version number in string ('001') |
Source code in client/ayon_core/lib/path_tools.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
version_up(filepath)
Version up filepath to a new non-existing version.
Parses for a version identifier like _v001
or .v001
When no version present _v001 is appended as suffix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath | str | full url | required |
Returns:
Type | Description |
---|---|
str | filepath with increased version number |
Source code in client/ayon_core/lib/path_tools.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|