added support for presets on global plugins

This commit is contained in:
Ondrej Samohel 2019-09-06 15:41:00 +02:00
parent 71a2b0e44d
commit dca53a183c
No known key found for this signature in database
GPG key ID: 8A29C663C672C2B7
2 changed files with 18 additions and 6 deletions

View file

@ -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:

View file

@ -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