fxfiles
FXProjectTemplate
A class representing an FX project template.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the project. |
root |
str
|
The root directory of the project. |
info |
dict
|
The project information. |
__str__
Returns a string representation of the FX project template.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the FX project template. |
from_json
classmethod
from_json(json_data: dict) -> FXProjectTemplate
Creates an FXProjectTemplate instance from a JSON object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data |
dict
|
The JSON data containing the project template information. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FXProjectTemplate |
FXProjectTemplate
|
The FXProjectTemplate instance created from the JSON data. |
Examples:
from_string
classmethod
from_string(input_string: str) -> FXProjectTemplate
Creates an FXProjectTemplate instance from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_string |
str
|
The string containing information to create the |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FXProjectTemplate |
FXProjectTemplate
|
The FXProjectTemplate instance created from the input string. |
Examples:
FXWorkfileTemplate
A class representing an FX workfile template.
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str
|
The sequence number. |
shot |
str
|
The shot number. |
step |
str
|
The step in the FX workflow. |
task |
str
|
The task associated with the workfile. |
version |
str
|
The version number. |
__str__
Returns a string representation of the FX workfile template.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the FX workfile template. |
from_string
classmethod
from_string(input_string: str, return_int: bool = True) -> FXWorkfileTemplate
Creates an FXWorkfileTemplate instance from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_string |
str
|
The string containing information to create the |
required |
return_int |
bool
|
If |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
FXWorkfileTemplate |
FXWorkfileTemplate
|
The FXWorkfileTemplate instance created from the input string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input string format is invalid. |
Examples:
create_child_from_dict
Recursively creates child folders and files based on the provided dict structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child_dict |
dict
|
The dictionary containing the child structure. |
required |
parent_dir |
str
|
The parent directory where the child will be created. |
required |
create_structure_from_dict
Creates the directory structure based on the provided dict structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure_dict |
dict
|
The dictionary containing the structure. |
required |
base_dir |
str
|
The base directory where the structure will be created. |
'.'
|
extract_version_integer_value
Extracts the integer value from a string in the format "vXXX".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string |
str
|
The input string containing the value in the format |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
Optional[int]
|
The integer value extracted from the input string. |
Examples:
find_version_in_filename
Finds the version number in a filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
The filename to search for the version number. |
required |
as_string |
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: The version number found in the filename, if any. |
get_all_metadata
Retrieve all metadata for a file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Path to the file or directory to retrieve metadata from. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Optional[str]]
|
Dictionary of all metadata names and their values. If a metadata entry |
Dict[str, Optional[str]]
|
is not found, its value is |
get_metadata_type
Determines the data type of a metadata value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata_name |
str
|
The name of the metadata entry. This is mostly used for special cases where the type can be determined based on the name only. |
required |
metadata_value |
str
|
The metadata value to determine the type of. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
type |
type
|
The data type of the metadata value. Returns |
get_multiple_metadata
Retrieve multiple metadata entries for a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Path to the file. |
required |
metadata_names |
List[str]
|
List of metadata names to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Optional[str]]
|
Dictionary of metadata names and their values. If a metadata entry is |
Dict[str, Optional[str]]
|
not found, its value is |
get_next_version
get_next_version(
path: str, as_string: bool = False, return_highest: bool = False
) -> Union[int, str]
Determines the next version number based on the existing versioned files in the given directory.
This function scans the specified directory for files with version numbers
at the end of their names, in the format _vNNN where N is a digit.
It identifies the highest version number currently present and returns the
next version number, incremented by one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str
|
The path to the directory containing the versioned files. |
required |
as_string |
bool
|
If |
False
|
return_highest |
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Union[int, str]
|
Union[int, str]: The next version number to be used, incremented by one from the highest existing version. Returns 1 if no versioned files are found. |
Examples:
path_to_unix
Replaces backward slashes with forward slashes (Unix format) in a given path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str
|
The input path containing backward slashes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path with all backward slashes replaced by forward slashes. |
Examples:
replace_placeholders_in_dict
Recursively replaces placeholders in a dictionary with values from another dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
Dict
|
The dictionary to process. |
required |
replacements |
Dict
|
The dictionary containing placeholder-replacement pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
The dictionary with placeholders replaced by values. |
replace_placeholders_in_string
Replaces placeholders in a string with values from a dictionary.
Note
Placeholders are in the format $placeholder$.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s |
str
|
The string to process. |
required |
replacements |
Dict
|
The dictionary containing placeholder-replacement pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string with placeholders replaced by values. |