Chore: Create plugin auto-apply settings (#5908)

* implemented default logic 'apply_settings' to auto-apply values

* added docstring to 'apply_settings'

* replace auto apply settings logic in maya

* add missing quote

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

---------

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
This commit is contained in:
Jakub Trllo 2023-11-14 14:57:53 +01:00 committed by GitHub
parent 05bbff0790
commit b382b7c776
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 20 deletions

View file

@ -271,7 +271,7 @@ class MayaCreatorBase(object):
@six.add_metaclass(ABCMeta)
class MayaCreator(NewCreator, MayaCreatorBase):
settings_name = None
settings_category = "maya"
def create(self, subset_name, instance_data, pre_create_data):
@ -317,24 +317,6 @@ class MayaCreator(NewCreator, MayaCreatorBase):
default=True)
]
def apply_settings(self, project_settings):
"""Method called on initialization of plugin to apply settings."""
settings_name = self.settings_name
if settings_name is None:
settings_name = self.__class__.__name__
settings = project_settings["maya"]["create"]
settings = settings.get(settings_name)
if settings is None:
self.log.debug(
"No settings found for {}".format(self.__class__.__name__)
)
return
for key, value in settings.items():
setattr(self, key, value)
class MayaAutoCreator(AutoCreator, MayaCreatorBase):
"""Automatically triggered creator for Maya.
@ -343,6 +325,8 @@ class MayaAutoCreator(AutoCreator, MayaCreatorBase):
any arguments.
"""
settings_category = "maya"
def collect_instances(self):
return self._default_collect_instances()
@ -360,6 +344,8 @@ class MayaHiddenCreator(HiddenCreator, MayaCreatorBase):
arguments for 'create' method.
"""
settings_category = "maya"
def create(self, *args, **kwargs):
return MayaCreator.create(self, *args, **kwargs)