mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
initial wip commit
This commit is contained in:
parent
b6869a9379
commit
f2a82d1afc
2 changed files with 90 additions and 3 deletions
|
|
@ -1,6 +1,11 @@
|
|||
import tempfile
|
||||
import os
|
||||
import pyblish.api
|
||||
import avalon.api
|
||||
from pprint import pprint
|
||||
|
||||
from pypeapp import config
|
||||
import inspect
|
||||
|
||||
ValidatePipelineOrder = pyblish.api.ValidatorOrder + 0.05
|
||||
ValidateContentsOrder = pyblish.api.ValidatorOrder + 0.1
|
||||
|
|
@ -8,7 +13,89 @@ ValidateSceneOrder = pyblish.api.ValidatorOrder + 0.2
|
|||
ValidateMeshOrder = pyblish.api.ValidatorOrder + 0.3
|
||||
|
||||
|
||||
class Extractor(pyblish.api.InstancePlugin):
|
||||
def imprint_attributes(plugin):
|
||||
"""
|
||||
Load presets by class and set them as attributes (if found)
|
||||
|
||||
:param plugin: plugin instance
|
||||
:type plugin: instance
|
||||
"""
|
||||
print("-" * 50)
|
||||
print("imprinting")
|
||||
file = inspect.getfile(plugin.__class__)
|
||||
file = os.path.normpath(file)
|
||||
plugin_kind = file.split(os.path.sep)[-2:-1][0]
|
||||
plugin_host = file.split(os.path.sep)[-3:-2][0]
|
||||
plugin_name = type(plugin).__name__
|
||||
print(file)
|
||||
print(plugin_kind)
|
||||
print(plugin_host)
|
||||
print(plugin_name)
|
||||
|
||||
pprint(config.get_presets()['plugins'])
|
||||
try:
|
||||
config_data = config.get_presets()['plugins'][plugin_host][plugin_kind][plugin_name] # noqa: E501
|
||||
except KeyError:
|
||||
print("preset not found")
|
||||
return
|
||||
|
||||
for option, value in config_data.items():
|
||||
if option == "enabled" and value is False:
|
||||
setattr(plugin, "active", False)
|
||||
else:
|
||||
setattr(plugin, option, value)
|
||||
print("setting {}: {} on {}".format(option, value, plugin_name))
|
||||
print("-" * 50)
|
||||
|
||||
|
||||
def add_init_presets(source_class):
|
||||
orig_init = source_class.__init__
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
imprint_attributes(self)
|
||||
print("overriding init")
|
||||
orig_init(self, *args, **kwargs)
|
||||
|
||||
source_class.__init__ = __init__
|
||||
return source_class
|
||||
|
||||
|
||||
def add_process_presets(source_class):
|
||||
orig_process = source_class.__init__
|
||||
|
||||
def process(self, *args, **kwargs):
|
||||
imprint_attributes(self)
|
||||
orig_process(self, *args, **kwargs)
|
||||
|
||||
source_class.__init__ = process
|
||||
return source_class
|
||||
|
||||
|
||||
@add_process_presets
|
||||
class ContextPlugin(pyblish.api.ContextPlugin):
|
||||
pass
|
||||
|
||||
|
||||
@add_process_presets
|
||||
class InstancePlugin(pyblish.api.InstancePlugin):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class PypeLoader(avalon.api.Loader):
|
||||
pass
|
||||
|
||||
|
||||
@add_init_presets
|
||||
class PypeCreator(avalon.api.Creator):
|
||||
pass
|
||||
|
||||
|
||||
avalon.api.Creator = PypeCreator
|
||||
|
||||
|
||||
|
||||
class Extractor(InstancePlugin):
|
||||
"""Extractor base class.
|
||||
|
||||
The extractor base class implements a "staging_dir" function used to
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import avalon.maya
|
||||
import pype.plugin
|
||||
|
||||
|
||||
class CreateModel(avalon.maya.Creator):
|
||||
class CreateModel(pype.plugin.PypeCreator):
|
||||
"""Polygonal static geometry"""
|
||||
|
||||
name = "modelMain"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue