From a08aa60902454c2aae1dcdbedf2bcf4f2419b412 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 30 Jun 2021 20:07:46 +0200 Subject: [PATCH] using ABC to define abstract methods and properties of Creator plugin --- openpype/pipeline/creator_plugins.py | 43 ++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/openpype/pipeline/creator_plugins.py b/openpype/pipeline/creator_plugins.py index 40b4657d96..3361bb5013 100644 --- a/openpype/pipeline/creator_plugins.py +++ b/openpype/pipeline/creator_plugins.py @@ -2,6 +2,13 @@ import copy import collections from uuid import uuid4 +from abc import ( + ABCMeta, + abstractmethod, + abstractproperty +) +import six + class AvalonInstance: """Instance entity with data that will be stored to workfile. @@ -56,6 +63,7 @@ class AvalonInstance: return AvalonInstance(family, subset_name, instance_data) +@six.add_metaclass(ABCMeta) class BaseCreator: """Plugin that create and modify instance data before publishing process. @@ -66,9 +74,8 @@ class BaseCreator: instance per one creator object. Do not store temp data or mid-process data to `self` if it's not Plugin specific. """ - # Abstract attributes - # Family that plugin represents - family = None + + # Creator is enabled (Probably does not have reason of existence?) enabled = True # GUI Purposes @@ -80,17 +87,19 @@ class BaseCreator: # - we may use UI inside processing this attribute should be checked self.headless = headless - def create(self, subset_name, instance_data, options=None): - """Create new instance in workfile metadata. + @abstractproperty + def family(self): + """Family that plugin represents.""" + pass + + @abstractmethod + def create(self, options=None): + """Create new instance. Replacement of `process` method from avalon implementation. - must expect all data that were passed to init in previous implementation """ - - # instance = InstanceData( - # self.family, subset_name, instance_data - # ) pass def get_default_variants(self): @@ -182,6 +191,22 @@ class Creator(BaseCreator): # Short description of family description = None + @abstractmethod + def create(self, subset_name, instance_data, options=None): + """Create new instance and store it. + + Ideally should be stored to workfile using host implementation. + + Args: + subset_name(str): Subset name of created instance. + instance_data(dict): + """ + + # instance = AvalonInstance( + # self.family, subset_name, instance_data + # ) + pass + def get_detail_description(self): """Description of family and plugin.