From 441b1776b070dcf2e1648ce5aa73e78cef9be734 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Wed, 19 Nov 2014 17:12:24 +0000 Subject: [PATCH 1/4] Augmenting logger, for Endpoint --- pyblish/lib.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyblish/lib.py b/pyblish/lib.py index c908dd8d..c9d1c12c 100644 --- a/pyblish/lib.py +++ b/pyblish/lib.py @@ -25,8 +25,14 @@ def log(cls): module = cls.__module__ name = cls.__name__ - logname = "%s.%s" % (module, name) + + # Package name appended, for filtering of LogRecord instances + logname = "pyblish.%s.%s" % (module, name) cls.log = logging.getLogger(logname) + + # All messages are handled by root-logger + cls.log.propagate = True + return cls From 333a09e69fe439b6a786d928432cd7a77e174434 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Wed, 19 Nov 2014 17:12:49 +0000 Subject: [PATCH 2/4] Augmenting log information, for more thorough debugging of invalid plug-ins --- pyblish/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyblish/plugin.py b/pyblish/plugin.py index 7a23f578..54f71217 100644 --- a/pyblish/plugin.py +++ b/pyblish/plugin.py @@ -972,11 +972,11 @@ def _isvalid(plugin): """Validate plugin""" if plugin.order is None: - log.error("Plug-in must have an order") + log.error("Plug-in must have an order: %s" % plugin) return False if not isinstance(plugin.requires, basestring): - log.error("Plug-in requires must be of type string") + log.error("Plug-in requires must be of type string: %s" % plugin) return False # Helper functions From f8357fc9b74f5df522e25b9f3960aecac15a7f2c Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Fri, 21 Nov 2014 10:56:32 +0000 Subject: [PATCH 3/4] Adding support for limiting which instances should be processed by a plug-in --- pyblish/plugin.py | 23 +++++++++++++++++++---- pyblish/tests/test_context.py | 27 ++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/pyblish/plugin.py b/pyblish/plugin.py index 54f71217..8303fb3f 100644 --- a/pyblish/plugin.py +++ b/pyblish/plugin.py @@ -137,14 +137,17 @@ def __str__(self): def __repr__(self): return u"%s.%s(%r)" % (__name__, type(self).__name__, self.__str__()) - def process(self, context): + def process(self, context, instances=None): """Perform processing upon context `context` + Arguments: + context (Context): Context to process + instances (list): Limit which instances to process + .. note:: If an instance contains the data "publish" and that data is `False` the instance will not be processed. Injected data during processing: - - `__is_processed__`: Whether or not the instance was processed - `__processed_by__`: Plugins which processed the given instance @@ -176,13 +179,25 @@ def process(self, context): for instance in compatible_instances: if instance.has_data('publish'): if instance.data('publish', default=True) is False: - self.log.info("Skipping %s" % instance) + self.log.info("Skipping %s, " + "publish-flag was false" % instance) continue elif not config['publish_by_default']: - self.log.info("Skipping %s" % instance) + self.log.info("Skipping %s, " + "no publish-flag was " + "set, and publishing " + "by default is False" % instance) continue + # Limit instances to those specified in `instances` + if instances is not None: + if not instance.data("name") in instances: + self.log.info("Skipping %s, " + "not included in " + "exclusion list" % instance) + continue + self.log.info("Processing instance: \"%s\"" % instance) # Inject data diff --git a/pyblish/tests/test_context.py b/pyblish/tests/test_context.py index 12742326..5910b7a9 100644 --- a/pyblish/tests/test_context.py +++ b/pyblish/tests/test_context.py @@ -6,7 +6,9 @@ import pyblish.lib import pyblish.plugin -# from pyblish.vendor.nose.tools import raises +from pyblish.tests.lib import ( + setup_full, teardown) +from pyblish.vendor.nose.tools import with_setup # Setup HOST = 'python' @@ -62,5 +64,28 @@ def test_instance_equality(): assert inst2 == inst3 +@with_setup(setup_full, teardown) +def test_limited_to_instances(): + """Only process instances specified in argument `instances`""" + ctx = pyblish.plugin.Context() + + for name in ("Instance01", "Instance02", "Instance03"): + inst = ctx.create_instance(name=name) + inst.set_data("family", "full") + + plugin = pyblish.plugin.discover(regex="ValidateInstance")[0] + assert plugin + + for inst, err in plugin().process(ctx, instances=["Instance01", + "Instance03"]): + assert err is None + + for inst in ctx: + name = inst.data("name") + if name in ["Instance01", "Instance03"]: + assert inst.data('validated', False) is True + if name == "Instance02": + assert inst.data('validated', False) is False + if __name__ == '__main__': test_add_remove_instances() From 8fceee481fda2fa0a15588e4afd63b2a6bde7671 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Mon, 1 Dec 2014 10:00:59 +0000 Subject: [PATCH 4/4] Version bump --- CHANGES | 5 +++++ pyblish/version.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 134d902e..6e9b1f01 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,11 @@ pyblish Changelog This contains all major version changes between pyblish releases. +Version 1.0.11 +-------------- + +- Added ability to process individual instances from within context + Version 1.0.10 -------------- diff --git a/pyblish/version.py b/pyblish/version.py index 355622cd..165fae2c 100644 --- a/pyblish/version.py +++ b/pyblish/version.py @@ -1,7 +1,7 @@ VERSION_MAJOR = 1 VERSION_MINOR = 0 -VERSION_PATCH = 10 +VERSION_PATCH = 11 version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) version = '%i.%i.%i' % version_info