mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
moved current actions to subdir
This commit is contained in:
parent
e4e8e7d520
commit
1e1828bbdc
3 changed files with 141 additions and 104 deletions
33
client/ayon_core/pipeline/actions/__init__.py
Normal file
33
client/ayon_core/pipeline/actions/__init__.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from .launcher import (
|
||||
LauncherAction,
|
||||
LauncherActionSelection,
|
||||
discover_launcher_actions,
|
||||
register_launcher_action,
|
||||
register_launcher_action_path,
|
||||
)
|
||||
|
||||
from .inventory import (
|
||||
InventoryAction,
|
||||
discover_inventory_actions,
|
||||
register_inventory_action,
|
||||
register_inventory_action_path,
|
||||
|
||||
deregister_inventory_action,
|
||||
deregister_inventory_action_path,
|
||||
)
|
||||
|
||||
|
||||
__all__= (
|
||||
"LauncherAction",
|
||||
"LauncherActionSelection",
|
||||
"discover_launcher_actions",
|
||||
"register_launcher_action",
|
||||
"register_launcher_action_path",
|
||||
|
||||
"InventoryAction",
|
||||
"discover_inventory_actions",
|
||||
"register_inventory_action",
|
||||
"register_inventory_action_path",
|
||||
"deregister_inventory_action",
|
||||
"deregister_inventory_action_path",
|
||||
)
|
||||
108
client/ayon_core/pipeline/actions/inventory.py
Normal file
108
client/ayon_core/pipeline/actions/inventory.py
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import logging
|
||||
|
||||
from ayon_core.pipeline.plugin_discover import (
|
||||
discover,
|
||||
register_plugin,
|
||||
register_plugin_path,
|
||||
deregister_plugin,
|
||||
deregister_plugin_path
|
||||
)
|
||||
from ayon_core.pipeline.load.utils import get_representation_path_from_context
|
||||
|
||||
|
||||
class InventoryAction:
|
||||
"""A custom action for the scene inventory tool
|
||||
|
||||
If registered the action will be visible in the Right Mouse Button menu
|
||||
under the submenu "Actions".
|
||||
|
||||
"""
|
||||
|
||||
label = None
|
||||
icon = None
|
||||
color = None
|
||||
order = 0
|
||||
|
||||
log = logging.getLogger("InventoryAction")
|
||||
log.propagate = True
|
||||
|
||||
@staticmethod
|
||||
def is_compatible(container):
|
||||
"""Override function in a custom class
|
||||
|
||||
This method is specifically used to ensure the action can operate on
|
||||
the container.
|
||||
|
||||
Args:
|
||||
container(dict): the data of a loaded asset, see host.ls()
|
||||
|
||||
Returns:
|
||||
bool
|
||||
"""
|
||||
return bool(container.get("objectName"))
|
||||
|
||||
def process(self, containers):
|
||||
"""Override function in a custom class
|
||||
|
||||
This method will receive all containers even those which are
|
||||
incompatible. It is advised to create a small filter along the lines
|
||||
of this example:
|
||||
|
||||
valid_containers = filter(self.is_compatible(c) for c in containers)
|
||||
|
||||
The return value will need to be a True-ish value to trigger
|
||||
the data_changed signal in order to refresh the view.
|
||||
|
||||
You can return a list of container names to trigger GUI to select
|
||||
treeview items.
|
||||
|
||||
You can return a dict to carry extra GUI options. For example:
|
||||
{
|
||||
"objectNames": [container names...],
|
||||
"options": {"mode": "toggle",
|
||||
"clear": False}
|
||||
}
|
||||
Currently workable GUI options are:
|
||||
- clear (bool): Clear current selection before selecting by action.
|
||||
Default `True`.
|
||||
- mode (str): selection mode, use one of these:
|
||||
"select", "deselect", "toggle". Default is "select".
|
||||
|
||||
Args:
|
||||
containers (list): list of dictionaries
|
||||
|
||||
Return:
|
||||
bool, list or dict
|
||||
|
||||
"""
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def filepath_from_context(cls, context):
|
||||
return get_representation_path_from_context(context)
|
||||
|
||||
|
||||
def discover_inventory_actions():
|
||||
actions = discover(InventoryAction)
|
||||
filtered_actions = []
|
||||
for action in actions:
|
||||
if action is not InventoryAction:
|
||||
filtered_actions.append(action)
|
||||
|
||||
return filtered_actions
|
||||
|
||||
|
||||
def register_inventory_action(plugin):
|
||||
return register_plugin(InventoryAction, plugin)
|
||||
|
||||
|
||||
def deregister_inventory_action(plugin):
|
||||
deregister_plugin(InventoryAction, plugin)
|
||||
|
||||
|
||||
def register_inventory_action_path(path):
|
||||
return register_plugin_path(InventoryAction, path)
|
||||
|
||||
|
||||
def deregister_inventory_action_path(path):
|
||||
return deregister_plugin_path(InventoryAction, path)
|
||||
|
|
@ -8,12 +8,8 @@ from ayon_core.pipeline.plugin_discover import (
|
|||
discover,
|
||||
register_plugin,
|
||||
register_plugin_path,
|
||||
deregister_plugin,
|
||||
deregister_plugin_path
|
||||
)
|
||||
|
||||
from .load.utils import get_representation_path_from_context
|
||||
|
||||
|
||||
class LauncherActionSelection:
|
||||
"""Object helper to pass selection to actions.
|
||||
|
|
@ -347,79 +343,6 @@ class LauncherAction(object):
|
|||
pass
|
||||
|
||||
|
||||
class InventoryAction(object):
|
||||
"""A custom action for the scene inventory tool
|
||||
|
||||
If registered the action will be visible in the Right Mouse Button menu
|
||||
under the submenu "Actions".
|
||||
|
||||
"""
|
||||
|
||||
label = None
|
||||
icon = None
|
||||
color = None
|
||||
order = 0
|
||||
|
||||
log = logging.getLogger("InventoryAction")
|
||||
log.propagate = True
|
||||
|
||||
@staticmethod
|
||||
def is_compatible(container):
|
||||
"""Override function in a custom class
|
||||
|
||||
This method is specifically used to ensure the action can operate on
|
||||
the container.
|
||||
|
||||
Args:
|
||||
container(dict): the data of a loaded asset, see host.ls()
|
||||
|
||||
Returns:
|
||||
bool
|
||||
"""
|
||||
return bool(container.get("objectName"))
|
||||
|
||||
def process(self, containers):
|
||||
"""Override function in a custom class
|
||||
|
||||
This method will receive all containers even those which are
|
||||
incompatible. It is advised to create a small filter along the lines
|
||||
of this example:
|
||||
|
||||
valid_containers = filter(self.is_compatible(c) for c in containers)
|
||||
|
||||
The return value will need to be a True-ish value to trigger
|
||||
the data_changed signal in order to refresh the view.
|
||||
|
||||
You can return a list of container names to trigger GUI to select
|
||||
treeview items.
|
||||
|
||||
You can return a dict to carry extra GUI options. For example:
|
||||
{
|
||||
"objectNames": [container names...],
|
||||
"options": {"mode": "toggle",
|
||||
"clear": False}
|
||||
}
|
||||
Currently workable GUI options are:
|
||||
- clear (bool): Clear current selection before selecting by action.
|
||||
Default `True`.
|
||||
- mode (str): selection mode, use one of these:
|
||||
"select", "deselect", "toggle". Default is "select".
|
||||
|
||||
Args:
|
||||
containers (list): list of dictionaries
|
||||
|
||||
Return:
|
||||
bool, list or dict
|
||||
|
||||
"""
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def filepath_from_context(cls, context):
|
||||
return get_representation_path_from_context(context)
|
||||
|
||||
|
||||
# Launcher action
|
||||
def discover_launcher_actions():
|
||||
return discover(LauncherAction)
|
||||
|
||||
|
|
@ -430,30 +353,3 @@ def register_launcher_action(plugin):
|
|||
|
||||
def register_launcher_action_path(path):
|
||||
return register_plugin_path(LauncherAction, path)
|
||||
|
||||
|
||||
# Inventory action
|
||||
def discover_inventory_actions():
|
||||
actions = discover(InventoryAction)
|
||||
filtered_actions = []
|
||||
for action in actions:
|
||||
if action is not InventoryAction:
|
||||
filtered_actions.append(action)
|
||||
|
||||
return filtered_actions
|
||||
|
||||
|
||||
def register_inventory_action(plugin):
|
||||
return register_plugin(InventoryAction, plugin)
|
||||
|
||||
|
||||
def deregister_inventory_action(plugin):
|
||||
deregister_plugin(InventoryAction, plugin)
|
||||
|
||||
|
||||
def register_inventory_action_path(path):
|
||||
return register_plugin_path(InventoryAction, path)
|
||||
|
||||
|
||||
def deregister_inventory_action_path(path):
|
||||
return deregister_plugin_path(InventoryAction, path)
|
||||
Loading…
Add table
Add a link
Reference in a new issue