File Utilities
renderkit.io.file_utils.FileUtils
Utility class for file operations.
Source code in src/renderkit/io/file_utils.py
14 15 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 72 73 74 75 76 77 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 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
convert_path_to_pattern(path_str)
staticmethod
Convert a file path to a frame sequence pattern string.
Source code in src/renderkit/io/file_utils.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
detect_sequence(pattern)
staticmethod
Detect a frame sequence and return the frame numbers.
Source code in src/renderkit/io/file_utils.py
148 149 150 151 152 | |
ensure_directory(path)
staticmethod
Ensure a directory exists, creating it if necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the directory |
required |
Source code in src/renderkit/io/file_utils.py
17 18 19 20 21 22 23 24 | |
find_files_by_pattern(directory, pattern, recursive=False)
staticmethod
Find files matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path
|
Directory to search |
required |
pattern
|
str
|
Filename pattern (supports wildcards) |
required |
recursive
|
bool
|
Whether to search recursively |
False
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of matching file paths |
Source code in src/renderkit/io/file_utils.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
get_file_extension(path)
staticmethod
Get the file extension (lowercase, without dot).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
Returns:
| Type | Description |
|---|---|
str
|
File extension |
Source code in src/renderkit/io/file_utils.py
26 27 28 29 30 31 32 33 34 35 36 | |
get_file_size(path)
staticmethod
Get file size in bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
Returns:
| Type | Description |
|---|---|
int
|
File size in bytes, or 0 if file doesn't exist |
Source code in src/renderkit/io/file_utils.py
70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_sample_frame_from_pattern(pattern)
staticmethod
Get a sample frame path from a sequence pattern.
Source code in src/renderkit/io/file_utils.py
154 155 156 157 158 159 160 161 162 163 164 165 166 | |
is_image_file(path)
staticmethod
Check if a file is a supported image format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if file is a supported image format |
Source code in src/renderkit/io/file_utils.py
38 39 40 41 42 43 44 45 46 47 48 | |
validate_output_filename(path_str)
staticmethod
Check if the output filename is valid for video encoding.
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
Tuple of (is_valid, error_message) |
Source code in src/renderkit/io/file_utils.py
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 | |
validate_output_path(path, overwrite=False)
staticmethod
Validate that output path can be written to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Output file path |
required |
overwrite
|
bool
|
Whether to allow overwriting existing files |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if path is valid for writing |
Source code in src/renderkit/io/file_utils.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |