mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
feat(pyblish): adding ability to filter and modify plugins based on presets
This commit is contained in:
parent
a955bafc55
commit
1f748ad0a2
2 changed files with 30 additions and 0 deletions
27
pype/lib.py
27
pype/lib.py
|
|
@ -478,3 +478,30 @@ def get_presets_path():
|
|||
path_items = [templates, 'presets']
|
||||
filepath = os.path.sep.join(path_items)
|
||||
return filepath
|
||||
|
||||
|
||||
def filter_pyblish_plugins(plugins):
|
||||
"""
|
||||
This servers as plugin filter / modifier for pyblish. It will load plugin
|
||||
definitions from presets and filter those needed to be excluded.
|
||||
|
||||
:param plugins: Dictionary of plugins produced by :mod:`pyblish-base`
|
||||
`discover()` method.
|
||||
:type plugins: Dict
|
||||
"""
|
||||
from pypeapp import config
|
||||
|
||||
# load plugins
|
||||
config_data = config.get_presets()['plugins']['config']
|
||||
|
||||
# iterate over plugins
|
||||
for plugin in plugins[:]:
|
||||
if config_data.get(plugin.__name__):
|
||||
for option, value in config_data[plugin.__name__].items():
|
||||
if hasattr(plugin, option):
|
||||
log.info('setting {}:{} on plugin {}'.format(
|
||||
option, value, plugin.__name__))
|
||||
setattr(plugin, option, value)
|
||||
if option == "enabled":
|
||||
log.info('removing plugin {}'.format(plugin.__name__))
|
||||
plugins.remove(plugin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue