Be notified of new releases
Create your free GitHub account today to subscribe to this repository for new releases and build software alongside 28 million developers.Sign up
Variable family-matching algorithms
This enables the use of multiple families of an instance to be associated with a plug-in, only when said families are a subset of the families supported by a plug-in.
That's a mouth full!
|Intersection||Include instances that match any supported family of plug-in (default)|
|Subset||Include instances that match all supported families of a plug-in|
|Exact||Include instances that include only supported families of a plug-in|
Let's see an example.
from pyblish import api class GenericPlugin(api.InstancePlugin): # Support both models and rigs families = ["model", "rig"] def process(self, instance): # Applies to both models and rigs assert "parent_GRP" in instance class SpecificPlugin(api.InstancePlugin): # Support models, but only low-poly models families = ["model", "low"] match = api.Subset def process(self, instance): # Applies to only low-poly models assert instance.data["polyCount"] < 500
In this example,
SpecificPlugin is associated to instances whose family(ies) are a subset of the supported families
low. If the instance does not have at least both of these, it is not a match.
This is different from
GenericPlugin, where only one of the families of an instance need to match any of the supported families of a plug-in.
match parameter then is a matching algorithm, as provided by standard set functionality.
# 1. Include on any match assert set(["a", "b"]).intersection(["b", "c"]) # 2. Include on all match assert set(["a", "b"]).issubset(["a", "b", "c"]) # 3. Include on exact match (note order is independent) assert set(["a", "b"]) == set(["b", "a"])
The default value for this parameter is
api.Intersection to preserve backwards compatibility. The last possible value is
api.Exact which means an instance only matches when families of both instance and plug-ins match exactly.
class EdgeCasePlugin(api.InstancePlugin): families = ["model", "low", "level21"] match = api.Exact def process(self, instance): assert "specialMember" in instance
test_logic.py for complete examples.