cgl.core.path package

Submodules

cgl.core.path.constants module

cgl.core.path.object module

class cgl.core.path.object.PathObject(project: str = '', path_dict: ~typing.Dict[str, str] = <factory>, sync_root: str = 'C:/alc/p4v', tree: str = '', entity_type: str = '', sequence: str = '', take: str = '', shot: str = '', task: str = '', category: str = '', asset_sub_type: str = '', asset: str = '', variant: str = '', user: str = '', version: str = '', major_version: str = '', minor_version: str = '', resolution: str = '', filebase: str = '', filename: str = '', ext: str = '', latest: bool = False, company: str = '', root: str = 'D:/a/cglumberjack/cglumberjack/alc_prod_root/Alchemy/CGL', game_root: str = '/Game', ue_root: str = '', ue_path: bool = False, world: str = '', content: str = '', msd: object | None = None, file_type: str | None = None, file_type_thumb: str | None = None, frame_range: str | None = None, stem: str = '', extras: ~typing.Dict[str, str] = <factory>, _resolved_template: ~typing.List[object] = <factory>, profile: str = 'alchemy', feature: str = 'alchemy', studio_profile: str = 'alchemy', studio_feature: str = 'alchemy', unreal_profile: str = 'alchemy', unreal_feature: str = 'unreal', season: str = '1', episode: str = '000', tokens_cfg: dict = <factory>, project_type: str = '')[source]

Bases: ConfigMixin, ValidationMixin, ParsingMixin, CopyMixin, UEMixin, ThumbsMixin, RenderingMixin, PublishMixin, VersioningMixin, MSDMixin, PathObject

Stable, public PathObject surface.

cgl.core.path.query module

cgl.core.path.query.find_letter_in_drives(letter)[source]

The function searches for a single letter in the available drives.

cgl.core.path.query.get_drives() dict[source]

The function retrieves a dictionary of the drives on the computer and their available space.

Returns:

a dictionary containing the drives on the computer and their available space.

cgl.core.path.sequence module

class cgl.core.path.sequence.Sequence(sequence, verbose=False)[source]

Bases: object

Class for dealing with “Sequences” of images or files in general as defined within a vfx/animation/games cookbook

end_frame = None
ext = None
frame_range = None
get_project_info()[source]
globals_info = {}
hash = None
hash_sequence = None
static int_as_padded_frame(number, padding=None)[source]

Given number, return a string with padding of padding.

Example

Given 3 return string with padding of 4 = 0003:

int_as_padded_frame(3, 4)
Parameters:
  • number (int) – The number to convert to a string with padding.

  • padding (int) – The number of digits to pad the string with.

Returns:

The number as a string with padding.

Return type:

str

is_valid_sequence()[source]

Checks “sequence” to ensure it matches our definition of a sequence: sequence.####.ext, sequence.%04d.ext, sequence.*.ext

Returns:

True if valid, False if not

Return type:

bool

middle_frame = None
num = None
num_sequence = None
padding = None
print_info()[source]
sequence = None
set_ext()[source]
sets the ext value for the sequence
Returns:

None

set_frange()[source]

Sets all information regarding frame range for the sequence start_frame, end_frame, middle_frame, frame_range are all set by this function

Returns:

None

set_sequence_strings()[source]

This is a utility function for setting all the various string formats we need for sequences depending on the software we happen to be working in: ####.exr - hash_sequence %04d.exr - num_sequence *.exr - star_sequence

Returns:

None

split_sequence()[source]

We split the sequence at the delimiter (‘*’, ‘%0Nd’, or ‘###’) and return the first value.

Example

split_sequence('sequence.####.exr')   returns 'sequence'
split_sequence('sequence.%04d.exr')   returns 'sequence'
split_sequence('sequence.*.exr')      returns 'sequence'
Returns:

The first part of the sequence string or None if the sequence is not valid.

Return type:

str

star_sequence = None
start_frame = None

cgl.core.path.support module

cgl.core.path.support.add_cookbook_root(filepath)[source]

Adds the cookbook root to the filepath

Parameters:

filepath – The filepath to be processed

Returns:

The filepath with the cookbook root added

cgl.core.path.support.add_root(path_)[source]
cgl.core.path.support.create_folders(path_object)[source]

Creates folders for the given path object. Creates folders for both the source and the render paths.

Parameters:

path_object – The path object to create folders for

Returns:

None

cgl.core.path.support.edit_project_msd(entity_object)[source]
cgl.core.path.support.edit_publish_msd(publish_path_object, wait=10)[source]

Edits the published MSD path to contain “publish” paths.

Parameters:
  • publish_path_object – The path object to be edited

  • wait (int) – The time to wait before editing the publish path (Default value = 10)

Returns:

True if the publish path was edited successfully, otherwise False

cgl.core.path.support.find_latest_publish_objects(folder, source=True, render=False)[source]

Returns all the latest published versions of the “folder” :param folder: The folder to find the latest published versions of :param source: Determines if source versions are to be returned (Default value = True) :type source: bool :param render: Determines if render versions are to be returned (Default value = False) :type render: bool

Returns:

A list of the latest published versions of the given folder

cgl.core.path.support.get_dcc_from_task_file(task_file)[source]

returns the dcc from a task file from the cookbook expecting a path like: cookbook/$DCC/tasks/$TASK.py :param task_file:

Returns:

cgl.core.path.support.get_folder_size(folder)[source]
Returns:

The size of the given folder including all children in bytes

Return type:

total_bytes (int)

Raises:

FileNotFoundError – If the folder does not exist

cgl.core.path.support.get_latest_asset_publish(project, sequence='*', asset=None, task='mdl')[source]
cgl.core.path.support.get_projects(company: str = '')[source]

Returns projects for “company”

Parameters:

company – The company to get the projects for (Default value = “”)

Returns:

A list of projects for the given company

cgl.core.path.support.get_short_name(string)[source]
cgl.core.path.support.get_task_default_file(task=None) list[source]

Returns the path to the default file of the given task

Parameters:

task – The task to get the default file of

Returns:

The path to the default file of the given task or None if no default file is found for the given task.

cgl.core.path.support.hd_proxy_exists(hd_proxy_path, frame_range)[source]
cgl.core.path.support.is_file(path_string)[source]

Uses regex to determine whether the string ends with a file extension or not. Assumes that if there’s an extension this is a file path that ends with a filename.

Parameters:

path_string – The path to be checked

Returns:

True if the path ends with a file extension, otherwise False

cgl.core.path.support.list_dir(path_object, variable)[source]

Lists what’s in the directory of the given variable, convenience function for working in the gui

Parameters:
  • path_object – The path object to be listed

  • variable – The variable to be listed

Returns:

A list of the given variable in the given path_object

cgl.core.path.support.lj_list_dir(directory: str, basename: bool = True, return_sequences: bool = False, full_range: bool = False, ignore_hidden: bool = True) List[str][source]

List directory contents with smart image-sequence grouping.

Delegates sequence logic (frame discovery, padding, ranges, missing frames) to Sequence. This function only:

  1. scans the directory,

  2. identifies unique sequence ‘heads’ (rightmost 1–7 digit block),

  3. instantiates one Sequence per head,

  4. formats display strings.

Non-sequence files are returned as-is.

cgl.core.path.support.open_file(filename: str) None[source]

It opens a file in the default application for that file type

Parameters:

filename – The path to the file to be opened

Returns:

None

Raises:

FileNotFoundError – If file named ‘filename’ does not exist

cgl.core.path.support.open_folder(file_path)[source]

opens the explorer/finder to the folder containing the file

cgl.core.path.support.path_delimit(path: str, to_windows=False) str[source]

It takes a path and returns a path with a linux/osx style path delimiter

Parameters:
  • to_windows – default is to return a linux style path string with “/” delimiter.

  • "" (Set to True if you need windows delimiters)

  • path – The path to be delimified

Returns:

The path with unified delimiters.

cgl.core.path.support.pick_best_default_item(items, variable)[source]
cgl.core.path.support.print_file_size(total_bytes, do_print=True)[source]

Returns a string with the size of the given file in Mb and bytes

Parameters:
  • total_bytes – The size of the file in bytes

  • do_print (bool) – Determines if file size is to be printed (Default value = True)

Returns:

A string with the size of the given file in Mb and bytes

cgl.core.path.support.read_publish_msd(user_render_dir)[source]
cgl.core.path.support.remove_coobkook_root(filepath)[source]

Removes the cookbook root from the filepath :param filepath:

Returns:

cgl.core.path.support.remove_root(filepath)[source]

Removes the root from the given filepath

Parameters:

filepath – The filepath to be processed

Returns:

The filepath with the root removed

cgl.core.path.support.replace_illegal_filename_characters(filename)[source]

Replaces illegal characters in a filename with underscores

Parameters:

filename (str) – The filename to be corrected

Returns:

Corrected file name

cgl.core.path.support.resolve_new_path(path_object, resolve_list)[source]
cgl.core.path.support.seq_from_file(filename, ext_map)[source]

Checks to see if a filename can be displayed as a hash_sequence :param filename: The filename to be checked :type filename: str :param ext_map: The ext_map to be used to check the filename

Returns:

The filename as a hash_sequence if it can be displayed as one, otherwise the original filename is returned

cgl.core.path.support.show_in_folder(path_string)[source]

Opens the folder containing the given path_string

Parameters:

path_string – The path to the file to be opened

Returns:

None

cgl.core.path.support.split_after(path_object, attr)[source]

Convenience function that returns the path after splitting it at the desired attribute.

For example, splitting a path at project would return the path up to and including the project variable:

split_after(path_object, "project")
Parameters:
  • path_object – The path object to be split

  • attr – The attribute to split the path at

Returns:

The path after splitting it at the desired attribute.

cgl.core.path.support.start(filepath)[source]

Opens a file on any os in the default application for that file type if given a folder, opens the os explorer to that location.

Parameters:

filepath – The path to the file to be opened

Returns:

None

Raises:

FileNotFoundError – If the file does not exist

cgl.core.path.support.start_url(url)[source]

Opens an url in the default browser

Parameters:

url

Returns:

None

cgl.core.path.version module

cgl.core.path.version.process_msd_file_list(file_list, new_root)[source]

processes a list of files, splits each string at “PUBLISHES” with a regex, and then joins the new root with the second half of the split string. :param file_list: :param new_root:

Returns:

cgl.core.path.version.pull_test()[source]
cgl.core.path.version.push(source_path, dest_path_object, publish=False)[source]

push a file or folder that is not in magic_browser to a destination pathObject

Parameters:
  • source_path (str) – source file or folder to push to the destination path object.

  • dest_path_object (PathObject) – path object where you want to push the files. Must be a user pathObject()

  • publish (bool) – publish the resulting pathObject()

Returns (PathObject):

publish pathObject()

cgl.core.path.version.push_test()[source]
cgl.core.path.version.remap_msd(source_object, dest_object)[source]

Remaps the msd for the pathObject - ensures all paths are going to the correct sync_root/company/project this is for use after a copy operation when you have to repath the msd file.

Parameters:

path_object (PathObject) – A PathObject instance that represents a path in the file system

Returns:

None

cgl.core.path.version.update_msd(path_object, dcc)[source]

Updates the msd for the pathObject

Module contents