mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
change automatic plugin config loading to settings
This commit is contained in:
parent
ad6b4bf895
commit
f7655dbb44
3 changed files with 13 additions and 10 deletions
|
|
@ -2,7 +2,7 @@ import os
|
|||
|
||||
from pyblish import api as pyblish
|
||||
from avalon import api as avalon
|
||||
from .api import config, Anatomy
|
||||
from .api import project_settings, Anatomy
|
||||
from .lib import filter_pyblish_plugins
|
||||
|
||||
|
||||
|
|
@ -50,14 +50,14 @@ def patched_discover(superclass):
|
|||
|
||||
print(">>> trying to find presets for {}:{} ...".format(host, plugin_type))
|
||||
try:
|
||||
config_data = config.get_presets()['plugins'][host][plugin_type]
|
||||
settings = project_settings(os.environ['AVALON_PROJECT'])[host][plugin_type]
|
||||
except KeyError:
|
||||
print("*** no presets found.")
|
||||
else:
|
||||
for plugin in plugins:
|
||||
if plugin.__name__ in config_data:
|
||||
if plugin.__name__ in settings:
|
||||
print(">>> We have preset for {}".format(plugin.__name__))
|
||||
for option, value in config_data[plugin.__name__].items():
|
||||
for option, value in settings[plugin.__name__].items():
|
||||
if option == "enabled" and value is False:
|
||||
setattr(plugin, "active", False)
|
||||
print(" - is disabled by preset")
|
||||
|
|
@ -104,6 +104,7 @@ def install():
|
|||
anatomy.set_root_environments()
|
||||
avalon.register_root(anatomy.roots)
|
||||
# apply monkey patched discover to original one
|
||||
log.info("Patching discovery")
|
||||
avalon.discover = patched_discover
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import os
|
|||
import inspect
|
||||
import logging
|
||||
|
||||
from ..api import config
|
||||
from ..api import config, project_settings
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -25,7 +25,7 @@ def filter_pyblish_plugins(plugins):
|
|||
|
||||
host = api.current_host()
|
||||
|
||||
presets = config.get_presets().get('plugins', {})
|
||||
presets = project_settings(os.environ['AVALON_PROJECT']) or {}
|
||||
|
||||
# iterate over plugins
|
||||
for plugin in plugins[:]:
|
||||
|
|
@ -53,7 +53,7 @@ def filter_pyblish_plugins(plugins):
|
|||
log.info('removing plugin {}'.format(plugin.__name__))
|
||||
plugins.remove(plugin)
|
||||
else:
|
||||
log.info('setting {}:{} on plugin {}'.format(
|
||||
log.info('setting XXX {}:{} on plugin {}'.format(
|
||||
option, value, plugin.__name__))
|
||||
|
||||
setattr(plugin, option, value)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import tempfile
|
|||
import os
|
||||
import pyblish.api
|
||||
|
||||
from pype.api import config
|
||||
from pype.api import project_settings
|
||||
import inspect
|
||||
|
||||
ValidatePipelineOrder = pyblish.api.ValidatorOrder + 0.05
|
||||
|
|
@ -24,12 +24,14 @@ def imprint_attributes(plugin):
|
|||
plugin_host = file.split(os.path.sep)[-3:-2][0]
|
||||
plugin_name = type(plugin).__name__
|
||||
try:
|
||||
config_data = config.get_presets()['plugins'][plugin_host][plugin_kind][plugin_name] # noqa: E501
|
||||
settings = project_settings(os.environ['AVALON_PROJECT'])
|
||||
settings_data = settings[plugin_host][plugin_kind][plugin_name] # noqa: E501
|
||||
print(settings_data)
|
||||
except KeyError:
|
||||
print("preset not found")
|
||||
return
|
||||
|
||||
for option, value in config_data.items():
|
||||
for option, value in settings_data.items():
|
||||
if option == "enabled" and value is False:
|
||||
setattr(plugin, "active", False)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue