CVEI I
Because the order of the above technique of (1) collecting, (2) validating and (3) extract-if-valid is so common, they are provided as keywords you can use in-place of a hard-coded number.
1
import pyblish.api
2
3
disk = {}
4
items = ["JOHN.person", "door.prop"]
5
6
class CollectInstances(pyblish.api.ContextPlugin):
7
8
order = pyblish.api.CollectorOrder # <-- This is new
9
10
def process(self, context):
11
for item in items:
12
name, suffix = item.split(".")
13
context.create_instance(name, family=suffix)
14
15
class ValidateNamingConvention(pyblish.api.InstancePlugin):
16
17
order = pyblish.api.ValidatorOrder
18
19
def process(self, instance):
20
name = instance.data["name"]
21
assert name == name.title(), "Sorry, %s should have been %s" % (
22
name, name.title())
23
24
class ExtractInstances(pyblish.api.InstancePlugin):
25
26
order = pyblish.api.ExtractorOrder
27
28
def process(self, instance):
29
disk[instance.data["name"]] = instance
30
31
pyblish.api.register_plugin(CollectInstances)
32
pyblish.api.register_plugin(ValidateNamingConvention)
33
pyblish.api.register_plugin(ExtractInstances)
34
35
import pyblish.util
36
pyblish.util.publish()
37
# Sorry, JOHN should have been John
38
# Sorry, door should have been Door
Copied!
Notice that instead of picking a number at random, we instead utilised the built-in order of CVEI. This not only simplifies determining the role of each plug-in, it also allows Pyblish to make some basic assumptions about your plug-ins, such as when to stop.
These constants are nothing more than integer numbers.
1
CollectorOrder: 0
2
ValidatorOrder: 1
3
ExtractorOrder: 2
Copied!
Together, they form the first three letters of "CVEI". We'll look at the last letter next.
Last modified 1yr ago
Copy link