Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

General: Move creators plugin getter #3714

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/load/load_layout_blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import bpy

from openpype import lib
from openpype.pipeline import (
legacy_create,
get_representation_path,
AVALON_CONTAINER_ID,
)
from openpype.pipeline.create import get_legacy_creator_by_name
from openpype.hosts.blender.api import plugin
from openpype.hosts.blender.api.pipeline import (
AVALON_CONTAINERS,
Expand Down Expand Up @@ -157,7 +157,7 @@ def _process(
t.id = local_obj

elif local_obj.type == 'EMPTY':
creator_plugin = lib.get_creator_by_name("CreateAnimation")
creator_plugin = get_legacy_creator_by_name("CreateAnimation")
if not creator_plugin:
raise ValueError("Creator plugin \"CreateAnimation\" was "
"not found.")
Expand Down
2 changes: 1 addition & 1 deletion openpype/hosts/blender/plugins/load/load_layout_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _process(self, libpath, asset, asset_group, actions):
# Camera creation when loading a layout is not necessary for now,
# but the code is worth keeping in case we need it in the future.
# # Create the camera asset and the camera instance
# creator_plugin = lib.get_creator_by_name("CreateCamera")
# creator_plugin = get_legacy_creator_by_name("CreateCamera")
# if not creator_plugin:
# raise ValueError("Creator plugin \"CreateCamera\" was "
# "not found.")
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/load/load_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import bpy

from openpype import lib
from openpype.pipeline import (
legacy_create,
get_representation_path,
AVALON_CONTAINER_ID,
)
from openpype.pipeline.create import get_legacy_creator_by_name
from openpype.hosts.blender.api import (
plugin,
get_selection,
Expand Down Expand Up @@ -244,7 +244,7 @@ def process_asset(
objects = self._process(libpath, asset_group, group_name, action)

if create_animation:
creator_plugin = lib.get_creator_by_name("CreateAnimation")
creator_plugin = get_legacy_creator_by_name("CreateAnimation")
if not creator_plugin:
raise ValueError("Creator plugin \"CreateAnimation\" was "
"not found.")
Expand Down
10 changes: 6 additions & 4 deletions openpype/hosts/maya/plugins/load/load_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from maya import cmds

from openpype.api import get_project_settings
from openpype.lib import get_creator_by_name
from openpype.pipeline import (
legacy_io,
from openpype.pipeline import legacy_io
from openpype.pipeline.create import (
legacy_create,
get_legacy_creator_by_name,
)
import openpype.hosts.maya.api.plugin
from openpype.hosts.maya.api.lib import maintained_selection
Expand Down Expand Up @@ -153,7 +153,9 @@ def _post_process_rig(self, name, namespace, context, options):
self.log.info("Creating subset: {}".format(namespace))

# Create the animation instance
creator_plugin = get_creator_by_name(self.animation_creator_name)
creator_plugin = get_legacy_creator_by_name(
self.animation_creator_name
)
with maintained_selection():
cmds.select([output, controls] + roots, noExpand=True)
legacy_create(
Expand Down
22 changes: 6 additions & 16 deletions openpype/lib/avalon_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ def BuildWorkfile():
return BuildWorkfile()


@with_pipeline_io
@deprecated("openpype.pipeline.create.get_legacy_creator_by_name")
def get_creator_by_name(creator_name, case_sensitive=False):
"""Find creator plugin by name.

Expand All @@ -780,23 +780,13 @@ def get_creator_by_name(creator_name, case_sensitive=False):

Returns:
Creator: Return first matching plugin or `None`.
"""
from openpype.pipeline import discover_legacy_creator_plugins

# Lower input creator name if is not case sensitive
if not case_sensitive:
creator_name = creator_name.lower()

for creator_plugin in discover_legacy_creator_plugins():
_creator_name = creator_plugin.__name__

# Lower creator plugin name if is not case sensitive
if not case_sensitive:
_creator_name = _creator_name.lower()
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.create import get_legacy_creator_by_name

if _creator_name == creator_name:
return creator_plugin
return None
return get_legacy_creator_by_name(creator_name, case_sensitive)


@deprecated
Expand Down
8 changes: 6 additions & 2 deletions openpype/pipeline/create/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
AutoCreator,
HiddenCreator,

discover_creator_plugins,
discover_legacy_creator_plugins,
get_legacy_creator_by_name,

discover_creator_plugins,
register_creator_plugin,
deregister_creator_plugin,
register_creator_plugin_path,
Expand Down Expand Up @@ -38,8 +40,10 @@
"AutoCreator",
"HiddenCreator",

"discover_creator_plugins",
"discover_legacy_creator_plugins",
"get_legacy_creator_by_name",

"discover_creator_plugins",
"register_creator_plugin",
"deregister_creator_plugin",
"register_creator_plugin_path",
Expand Down
28 changes: 28 additions & 0 deletions openpype/pipeline/create/creator_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,34 @@ def discover_legacy_creator_plugins():
return plugins


def get_legacy_creator_by_name(creator_name, case_sensitive=False):
"""Find creator plugin by name.

Args:
creator_name (str): Name of creator class that should be returned.
case_sensitive (bool): Match of creator plugin name is case sensitive.
Set to `False` by default.

Returns:
Creator: Return first matching plugin or `None`.
"""

# Lower input creator name if is not case sensitive
if not case_sensitive:
creator_name = creator_name.lower()

for creator_plugin in discover_legacy_creator_plugins():
_creator_name = creator_plugin.__name__

# Lower creator plugin name if is not case sensitive
if not case_sensitive:
_creator_name = _creator_name.lower()

if _creator_name == creator_name:
return creator_plugin
return None


def register_creator_plugin(plugin):
if issubclass(plugin, BaseCreator):
register_plugin(BaseCreator, plugin)
Expand Down