mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added support for presets on global plugins
This commit is contained in:
parent
71a2b0e44d
commit
dca53a183c
2 changed files with 18 additions and 6 deletions
22
pype/lib.py
22
pype/lib.py
|
|
@ -5,6 +5,7 @@ import importlib
|
|||
import itertools
|
||||
import contextlib
|
||||
import subprocess
|
||||
import inspect
|
||||
|
||||
from .vendor import pather
|
||||
from .vendor.pather.error import ParseError
|
||||
|
|
@ -467,9 +468,7 @@ def filter_pyblish_plugins(plugins):
|
|||
|
||||
host = api.current_host()
|
||||
|
||||
presets = config.get_presets().get('plugins', {}).get(host, {}).get(
|
||||
"publish", {}
|
||||
)
|
||||
presets = config.get_presets().get('plugins', {})
|
||||
|
||||
# iterate over plugins
|
||||
for plugin in plugins[:]:
|
||||
|
|
@ -477,10 +476,23 @@ def filter_pyblish_plugins(plugins):
|
|||
if not presets:
|
||||
continue
|
||||
|
||||
file = os.path.normpath(inspect.getfile(plugin.__class__))
|
||||
file = os.path.normpath(file)
|
||||
|
||||
# host determined from path
|
||||
host_from_file = file.split(os.path.sep)[-3:-2][0]
|
||||
plugin_kind = file.split(os.path.sep)[-2:-1][0]
|
||||
|
||||
print(host_from_file)
|
||||
print(plugin_kind)
|
||||
|
||||
try:
|
||||
config_data = presets[plugin.__name__] # noqa: E501
|
||||
config_data = presets[host]["publish"][plugin.__name__]
|
||||
except KeyError:
|
||||
continue
|
||||
try:
|
||||
config_data = presets[host_from_file][plugin_kind][plugin.__name__] # noqa: E501
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
for option, value in config_data.items():
|
||||
if option == "enabled" and value is False:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def test_pyblish_plugin_filter_modifier(printer, monkeypatch):
|
|||
assert len(plugins) == 0
|
||||
paths = pyblish.api.registered_paths()
|
||||
printer("Test if we have no registered plugin paths")
|
||||
print(paths)
|
||||
assert len(paths) == 0
|
||||
|
||||
class MyTestPlugin(pyblish.api.InstancePlugin):
|
||||
my_test_property = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue