mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Remove unused code
This commit is contained in:
parent
9294a21635
commit
fe4a15dc4f
2 changed files with 2 additions and 127 deletions
|
|
@ -24,8 +24,7 @@ from .lib import (
|
||||||
lsattrs,
|
lsattrs,
|
||||||
read,
|
read,
|
||||||
|
|
||||||
maintained_selection,
|
maintained_selection
|
||||||
unique_name
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -51,8 +50,7 @@ __all__ = [
|
||||||
"lsattrs",
|
"lsattrs",
|
||||||
"read",
|
"read",
|
||||||
|
|
||||||
"maintained_selection",
|
"maintained_selection"
|
||||||
"unique_name"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Backwards API compatibility
|
# Backwards API compatibility
|
||||||
|
|
|
||||||
|
|
@ -99,65 +99,6 @@ def get_id_required_nodes():
|
||||||
return list(nodes)
|
return list(nodes)
|
||||||
|
|
||||||
|
|
||||||
def get_additional_data(container):
|
|
||||||
"""Not implemented yet!"""
|
|
||||||
return container
|
|
||||||
|
|
||||||
|
|
||||||
def set_parameter_callback(node, parameter, language, callback):
|
|
||||||
"""Link a callback to a parameter of a node
|
|
||||||
|
|
||||||
Args:
|
|
||||||
node(hou.Node): instance of the nodee
|
|
||||||
parameter(str): name of the parameter
|
|
||||||
language(str): name of the language, e.g.: python
|
|
||||||
callback(str): command which needs to be triggered
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
None
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
template_grp = node.parmTemplateGroup()
|
|
||||||
template = template_grp.find(parameter)
|
|
||||||
if not template:
|
|
||||||
return
|
|
||||||
|
|
||||||
script_language = (hou.scriptLanguage.Python if language == "python" else
|
|
||||||
hou.scriptLanguage.Hscript)
|
|
||||||
|
|
||||||
template.setScriptCallbackLanguage(script_language)
|
|
||||||
template.setScriptCallback(callback)
|
|
||||||
|
|
||||||
template.setTags({"script_callback": callback,
|
|
||||||
"script_callback_language": language.lower()})
|
|
||||||
|
|
||||||
# Replace the existing template with the adjusted one
|
|
||||||
template_grp.replace(parameter, template)
|
|
||||||
|
|
||||||
node.setParmTemplateGroup(template_grp)
|
|
||||||
|
|
||||||
|
|
||||||
def set_parameter_callbacks(node, parameter_callbacks):
|
|
||||||
"""Set callbacks for multiple parameters of a node
|
|
||||||
|
|
||||||
Args:
|
|
||||||
node(hou.Node): instance of a hou.Node
|
|
||||||
parameter_callbacks(dict): collection of parameter and callback data
|
|
||||||
example: {"active" :
|
|
||||||
{"language": "python",
|
|
||||||
"callback": "print('hello world)'"}
|
|
||||||
}
|
|
||||||
Returns:
|
|
||||||
None
|
|
||||||
"""
|
|
||||||
for parameter, data in parameter_callbacks.items():
|
|
||||||
language = data["language"]
|
|
||||||
callback = data["callback"]
|
|
||||||
|
|
||||||
set_parameter_callback(node, parameter, language, callback)
|
|
||||||
|
|
||||||
|
|
||||||
def get_output_parameter(node):
|
def get_output_parameter(node):
|
||||||
"""Return the render output parameter name of the given node
|
"""Return the render output parameter name of the given node
|
||||||
|
|
||||||
|
|
@ -189,19 +130,6 @@ def get_output_parameter(node):
|
||||||
raise TypeError("Node type '%s' not supported" % node_type)
|
raise TypeError("Node type '%s' not supported" % node_type)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def attribute_values(node, data):
|
|
||||||
|
|
||||||
previous_attrs = {key: node.parm(key).eval() for key in data.keys()}
|
|
||||||
try:
|
|
||||||
node.setParms(data)
|
|
||||||
yield
|
|
||||||
except Exception as exc:
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
node.setParms(previous_attrs)
|
|
||||||
|
|
||||||
|
|
||||||
def set_scene_fps(fps):
|
def set_scene_fps(fps):
|
||||||
hou.setFps(fps)
|
hou.setFps(fps)
|
||||||
|
|
||||||
|
|
@ -349,10 +277,6 @@ def render_rop(ropnode):
|
||||||
raise RuntimeError("Render failed: {0}".format(exc))
|
raise RuntimeError("Render failed: {0}".format(exc))
|
||||||
|
|
||||||
|
|
||||||
def children_as_string(node):
|
|
||||||
return [c.name() for c in node.children()]
|
|
||||||
|
|
||||||
|
|
||||||
def imprint(node, data):
|
def imprint(node, data):
|
||||||
"""Store attributes with value on a node
|
"""Store attributes with value on a node
|
||||||
|
|
||||||
|
|
@ -473,53 +397,6 @@ def read(node):
|
||||||
parameter in node.spareParms()}
|
parameter in node.spareParms()}
|
||||||
|
|
||||||
|
|
||||||
def unique_name(name, format="%03d", namespace="", prefix="", suffix="",
|
|
||||||
separator="_"):
|
|
||||||
"""Return unique `name`
|
|
||||||
|
|
||||||
The function takes into consideration an optional `namespace`
|
|
||||||
and `suffix`. The suffix is included in evaluating whether a
|
|
||||||
name exists - such as `name` + "_GRP" - but isn't included
|
|
||||||
in the returned value.
|
|
||||||
|
|
||||||
If a namespace is provided, only names within that namespace
|
|
||||||
are considered when evaluating whether the name is unique.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
format (str, optional): The `name` is given a number, this determines
|
|
||||||
how this number is formatted. Defaults to a padding of 2.
|
|
||||||
E.g. my_name01, my_name02.
|
|
||||||
namespace (str, optional): Only consider names within this namespace.
|
|
||||||
suffix (str, optional): Only consider names with this suffix.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
>>> name = hou.node("/obj").createNode("geo", name="MyName")
|
|
||||||
>>> assert hou.node("/obj/MyName")
|
|
||||||
True
|
|
||||||
>>> unique = unique_name(name)
|
|
||||||
>>> assert hou.node("/obj/{}".format(unique))
|
|
||||||
False
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
iteration = 1
|
|
||||||
|
|
||||||
parts = [prefix, name, format % iteration, suffix]
|
|
||||||
if namespace:
|
|
||||||
parts.insert(0, namespace)
|
|
||||||
|
|
||||||
unique = separator.join(parts)
|
|
||||||
children = children_as_string(hou.node("/obj"))
|
|
||||||
while unique in children:
|
|
||||||
iteration += 1
|
|
||||||
unique = separator.join(parts)
|
|
||||||
|
|
||||||
if suffix:
|
|
||||||
return unique[:-len(suffix)]
|
|
||||||
|
|
||||||
return unique
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def maintained_selection():
|
def maintained_selection():
|
||||||
"""Maintain selection during context
|
"""Maintain selection during context
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue