From b9895017c87d4d9c7f74d200c8d3a2f29c5e012a Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 9 Jun 2015 16:51:39 +0100 Subject: [PATCH] Implemented in #196 --- pyblish/plugin.py | 3 +++ tests/test_plugin.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/pyblish/plugin.py b/pyblish/plugin.py index ae739302..a22ee24f 100644 --- a/pyblish/plugin.py +++ b/pyblish/plugin.py @@ -866,6 +866,9 @@ def discover(type=None, regex=None, paths=None): continue for fname in os.listdir(path): + if fname.startswith("_"): + continue + abspath = os.path.join(path, fname) if not os.path.isfile(abspath): diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 79615ff2..3b4bcf6f 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -176,3 +176,35 @@ def _current_host(): finally: sys.executable = old + +@with_setup(lib.setup_empty, lib.teardown) +def test_temporarily_disabled_plugins(): + """Plug-ins as files starting with an underscore are hidden""" + + discoverable = """ +import pyblish.api + +class Discoverable(pyblish.api.Plugin): + pass +""" + + notdiscoverable = """ +import pyblish.api + +class NotDiscoverable(pyblish.api.Plugin): + pass +""" + + with tempdir() as d: + pyblish.api.register_plugin_path(d) + + with open(os.path.join(d, "discoverable.py"), "w") as f: + f.write(discoverable) + + with open(os.path.join(d, "_undiscoverable.py"), "w") as f: + f.write(notdiscoverable) + + + plugins = [p.__name__ for p in pyblish.api.discover()] + assert "Discoverable" in plugins + assert "NotDiscoverable" not in plugins