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:
- Raises:
MissingPresetPath – When the Provided Preset file path has no value
- availableConfigTypes()¶
Returns all currently available naming configuration hive Types.
- 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.
- findPreset(name)¶
Return the preset by the name, None if not found.
- 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.
- 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()
- deletePreset(preset)¶
Removes the given preset from the manager and deletes the preset file as well as any attached configurations.
- 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:
- 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”
- 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:
- classmethod loadFromPath(path)¶
Loads the preset from a valid file path, must be valid json data.
- classmethod loadFromData(data, filePath, parent=None)¶
Loads the preset from the provided data.
- 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:
- Return type:
- removeConfigByName(name)¶
Removes the configuration by name from the preset however doesn’t delete the config off. disk.
- removeConfigByHiveType(hiveType)¶
Removes The config by the hive type however doesn’t delete the config off.
- deleteAllConfigs()¶
Deletes all configuration instances from disk.
- Returns:
Whether deletion was successful.
- Return type:
- 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:
- findConfigDataByHiveType(hiveType, recursive=True)¶
Returns the configuration Data instance stored on the preset.
- Parameters:
hiveType (str) – The component hive type.
- Return type:
- 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:
- class NameConfigData(name, hiveType)¶
Bases:
object
Data class which stores the config name, hiveType and linked name Manager configuration on a preset.
- surroundTextAsField(text)¶
Returns the text with the field syntax added.
text = surroundTextAsField("myField") # "{text}"
- 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 filtername (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:
- uniqueNameForRig(rigs, name)¶
Returns a unique name for the component using a rig instance.
- Parameters:
rigs (tuple(
zoo.libs.hive.base.rig.Rig
)) – The rig instance to use as the filtername (str) – The new name for the component.
- Returns:
A unique name will be returned eg. ‘arm’ may return arm001
- Return type:
- composeComponentRootNames(config, compName, compSide)¶
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.
- Returns:
first element is the root Hrc Name, second element is the Meta Node name
- Return type:
- 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:
- 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:
- composeContainerName(config, compName, compSide)¶
Composes and returns the resolved node name for the component container node.
- Parameters:
config (
zoo.libs.naming.naming.NameManager
) – The naming configuration instance.compName (str) – The component name
compSide (str) – The component side name.
- Returns:
The resolved name for the container
- Return type:
- composeAnnotationGrpName(config, compName, compSide)¶
Composes and returns the resolved node names for the component Annotation group transform node.
- Parameters:
config (
zoo.libs.naming.naming.NameManager
) – The naming configuration instance.compName (str) – The component name
compSide (str) – The component side name.
- Returns:
Resolved name for the annotation group
- Return type:
- 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: