mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
defined class which defined base settings
This commit is contained in:
parent
3e87997b40
commit
aa2f5d8570
2 changed files with 82 additions and 2 deletions
|
|
@ -1,16 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from .base import (
|
||||
OpenPypeModule,
|
||||
OpenPypeAddOn,
|
||||
OpenPypeInterface,
|
||||
|
||||
ModulesManager,
|
||||
TrayModulesManager
|
||||
TrayModulesManager,
|
||||
|
||||
ModuleSettingsDef,
|
||||
get_module_settings_defs
|
||||
)
|
||||
|
||||
|
||||
__all__ = (
|
||||
"OpenPypeModule",
|
||||
"OpenPypeAddOn",
|
||||
"OpenPypeInterface",
|
||||
|
||||
"ModulesManager",
|
||||
"TrayModulesManager"
|
||||
"TrayModulesManager",
|
||||
|
||||
"ModuleSettingsDef",
|
||||
"get_module_settings_defs"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -920,3 +920,74 @@ class TrayModulesManager(ModulesManager):
|
|||
),
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
|
||||
def get_module_settings_defs():
|
||||
load_modules()
|
||||
|
||||
import openpype_modules
|
||||
|
||||
settings_defs = []
|
||||
|
||||
log = PypeLogger.get_logger("ModuleSettingsLoad")
|
||||
|
||||
for raw_module in openpype_modules:
|
||||
for attr_name in dir(raw_module):
|
||||
attr = getattr(raw_module, attr_name)
|
||||
if (
|
||||
not inspect.isclass(attr)
|
||||
or attr is ModuleSettingsDef
|
||||
or not issubclass(attr, ModuleSettingsDef)
|
||||
):
|
||||
continue
|
||||
|
||||
if inspect.isabstract(attr):
|
||||
# Find missing implementations by convetion on `abc` module
|
||||
not_implemented = []
|
||||
for attr_name in dir(attr):
|
||||
attr = getattr(attr, attr_name, None)
|
||||
abs_method = getattr(
|
||||
attr, "__isabstractmethod__", None
|
||||
)
|
||||
if attr and abs_method:
|
||||
not_implemented.append(attr_name)
|
||||
|
||||
# Log missing implementations
|
||||
log.warning((
|
||||
"Skipping abstract Class: {} in module {}."
|
||||
" Missing implementations: {}"
|
||||
).format(
|
||||
attr_name, raw_module.__name__, ", ".join(not_implemented)
|
||||
))
|
||||
continue
|
||||
|
||||
settings_defs.append(attr)
|
||||
|
||||
return settings_defs
|
||||
|
||||
|
||||
@six.add_metaclass(ABCMeta)
|
||||
class ModuleSettingsDef:
|
||||
@abstractmethod
|
||||
def get_system_schemas(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_project_schemas(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def save_system_defaults(self, data):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def save_project_defaults(self, data):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_system_defaults(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_project_defaults(self):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue