Hive Naming

Module which handles all preset naming configurations.

Example preset in raw data form.

{
    "name": "ZooToolsPro",
    "configs": [
        {
            "name": "zootoolsProGlobalConfig",
            "hiveType": "global"
        }
    ]
}
exception MissingPresetPath(preset)

Bases: Exception

Called when the preset doesn’t have a file path.

class PresetManager

Bases: object

Manager for naming presets

ENV_VAR = 'HIVE_NAME_PRESET_PATH'
static savePreset(preset)

Saves the given preset onto disk.

Note:

The preset must have a file path specified.

Parameters:

preset (Preset) – The preset instance to save.

Returns:

Whether the file successfully saved.

Return type:

bool

Raises:

MissingPresetPath – When the Provided Preset file path has no value

availableConfigTypes()

Returns all currently available naming configuration hive Types.

Return type:

set[str]

updateAvailableConfigTypes(types)

Updates the currently available config types, when a class instance is first created the list will update from the found preset configuration.

containsPath(filePath)

Whether the file path has already been loaded.

Parameters:

filePath (str) – The file path to search for.

Returns:

Return type:

bool

findPreset(name)

Return the preset by the name, None if not found.

Parameters:

name (str) – The preset name to search for

Return type:

Preset or None

createPreset(name, directory, parent=None)

Creates but does not save to disk a new preset instance.

Call PresetManager.savePreset() to save the preset to disk.

Parameters:
  • name (str) – The name for the preset.

  • directory (str) – The directory where the preset will be created.

  • parent (Preset) – The parent Preset for the new preset

Returns:

The newly created preset.

Return type:

Preset

removePreset(presetName)

Remove the preset by name and returns whether deletion was successfully.

This Method only remove’s the preset from memory but doesn’t delete it on disk. You should call PresetManager.deletePreset()

Note:

This method will also modify the parent preset.

Parameters:

presetName (str) – The preset name to search for

Return type:

bool

deletePreset(preset)

Removes the given preset from the manager and deletes the preset file as well as any attached configurations.

Parameters:

preset (Preset) – The preset instance to delete from disk.

Return type:

bool

configSaveFolder()

The current folder which all new presets get saved too.

Return type:

str

saveConfig(config)

Saves the given config instance to disk.

Parameters:

config (naming.NameManager) – The config instance to save.

Returns:

Whether the file successfully saved.

Return type:

bool

loadFromEnv(hierarchy)

Loads all presets and constructs the preset hierarchy from the preset environment variable.

Note

Calling this method will clear the cache which stores all presets and configs.

Parameters:

hierarchy (dict) –

loadFromFile(path)

Loads the provided file path which is either a preset or naming configuration.

Parameters:

path (str) – The file path to load, must be either file format . “.namingcfg” or “.namingpreset”

loadFromDirectoryPath(path)

Recursively loads all naming presets or configs from the provided folder

Parameters:

path (str) – Absolute file path to the naming preset of config to load

hierarchyData()

Returns the current hierarchy raw data from the current preset hierarchy.

data = preset.hierarchyData()
# {"name": "ZooToolsPro",
# "children": [{"name": "UE5Manniquin"}]
# }
Return type:

dict

class Preset(name, filePath, parent)

Bases: object

Naming Preset class which managers configurations.

A Preset data is in the form of

{
    "name": "ZooToolsPro",
    "configs": [
    {
        "name": "zootoolsProGlobalConfig",
        "hiveType": "global"
    }]
}
Parameters:
  • name (str) – The preset name

  • filePath (str) – The file path for the preset, note. it doesn’t need to exist.

  • parent (Preset) – The parent preset.

classmethod loadFromPath(path)

Loads the preset from a valid file path, must be valid json data.

Parameters:

path (str) – The preset json file path to load.

Returns:

The new loaded preset.

Return type:

Preset

classmethod loadFromData(data, filePath, parent=None)

Loads the preset from the provided data.

Parameters:
  • data (dict) – The raw preset data to load.

  • filePath (str) – The file path for the preset.

  • parent (Preset) – The parent preset instance

Returns:

The newly loaded preset instance.

Return type:

Preset

serialize()

Returns the raw dict representing this preset.

Return type:

dict

exists()

Whether this preset exists on disk.

Return type:

bool

createConfig(name, hiveType, fields=None, rules=None)

Creates but doesn’t save to disk a new name configuration and adds it to the preset.

Parameters:
  • name (str) – The Configuration name to use.

  • hiveType (str) – The hive component type to link too.

  • fields (list[dict]) – The fields to set on the newly created config.

  • rules (list[dict]) – The rules to set on the newly created config.

Return type:

NameConfigData

removeConfigByName(name)

Removes the configuration by name from the preset however doesn’t delete the config off. disk.

Parameters:

name (str) – The name of the configuration to remove.

Returns:

Whether removal was successful.

Return type:

bool

removeConfigByHiveType(hiveType)

Removes The config by the hive type however doesn’t delete the config off.

Parameters:

hiveType (str) – The hive component type search for.

Returns:

Whether removal was successful.

Return type:

bool

deleteAllConfigs()

Deletes all configuration instances from disk.

Returns:

Whether deletion was successful.

Return type:

bool

deleteConfig(config)

Deletes the configuration instance from disk

Parameters:

config (naming.NameManager) – The naming configuration instance to delete.

Returns:

Whether deletion was successful.

Return type:

bool

findConfigDataByHiveType(hiveType, recursive=True)

Returns the configuration Data instance stored on the preset.

Parameters:

hiveType (str) – The component hive type.

Return type:

NameConfigData

findNamingConfigByName(name, recursive=True)

Returns the naming configuration instance by name.

Parameters:

name (str) – The name of the configuration to find.

Return type:

naming.NameManager

findNamingConfigForType(hiveType, recursive=True)

Finds and returns the naming convention config for the hive Type.

The Hive Type is one of three keys either “rig”, “global” or the component Type.

Parameters:

hiveType (str) – The Hive Type to search for, ie. componentType, “rig” or “global”

Returns:

The naming configuration Manager instance

Return type:

zoo.libs.naming.naming.NameManager

class NameConfigData(name, hiveType)

Bases: object

Data class which stores the config name, hiveType and linked name Manager configuration on a preset.

serialize()

Returns the raw representation of the configuration which only contains the Name and hiveType keys.

Return type:

dict

surroundTextAsField(text)

Returns the text with the field syntax added.

text = surroundTextAsField("myField")
# "{text}"
Parameters:

text (str) – The text to surround

Return type:

str

uniqueNameForComponentByRig(rig, name, side)

Returns a unique name for the component using a rig instance.

Parameters:
  • rig (zoo.libs.hive.base.rig.Rig) – The rig instance to use as the filter

  • name (str) – The new name for the component.

  • side (str) – The component side name.

Returns:

A unique name will be returned eg. ‘arm’ may return arm001

Return type:

str

uniqueNameForRig(rigs, name)

Returns a unique name for the component using a rig instance.

Parameters:
Returns:

A unique name will be returned eg. ‘arm’ may return arm001

Return type:

str

composeComponentRootNames(config, compName, compSide)

Composes and returns the resolved node names for the component root HRC and meta nodes.

Parameters:
Returns:

first element is the root Hrc Name, second element is the Meta Node name

Return type:

tuple[str, str]

composeRigNamesForLayer(config, rigName, layerType)

Composes and returns the resolved node names for the layer root HRC and meta nodes.

Parameters:
  • config (zoo.libs.naming.naming.NameManager) – The naming configuration instance.

  • rigName (str) – The component name

  • layerType – The hive layer type name to resolve ie. api.constants.GUIDE_LAYER_TYPE.

Returns:

first element is the root Hrc Name, second element is the Meta Node name

Return type:

tuple[str, str]

composeNamesForLayer(config, compName, compSide, layerType)

Composes and returns the resolved node names for the layer root HRC and meta nodes.

Parameters:
  • config (zoo.libs.naming.naming.NameManager) – The naming configuration instance.

  • compName (str) – The component name

  • compSide (str) – The component side name.

  • layerType – The hive layer type name to resolve ie. api.constants.GUIDE_LAYER_TYPE.

Returns:

first element is the root Hrc Name, second element is the Meta Node name

Return type:

tuple[str, str]

composeContainerName(config, compName, compSide)

Composes and returns the resolved node name for the component container node.

Parameters:
Returns:

The resolved name for the container

Return type:

str

composeAnnotationGrpName(config, compName, compSide)

Composes and returns the resolved node names for the component Annotation group transform node.

Parameters:
Returns:

Resolved name for the annotation group

Return type:

str

composeSettingsName(config, compName, compSide, section)

Composes and returns the resolved node names for the component root HRC and meta nodes.

Parameters:
  • config (zoo.libs.naming.naming.NameManager) – The naming configuration instance.

  • compName (str) – The component name

  • compSide (str) – The component side name.

  • section – The settings unique section name ie. “controlPanel”

Returns:

The resolved name for the settings node

Return type:

str