Publishing is about finding problems and the only way to find them is by bringing them to the surface, to visualise them. So in this example, we'll have a look at how you can do just that.
We can use the results produced during publishing to pretty-print ourselves a report of how things went. This is what we will be producing in this example.
import pyblish.apiclassCollectCaptainAmerica(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrderdefprocess(self,context): context.create_instance("Captain America", isHero=False)classValidateCaptainAmerica(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrderdefprocess(self,instance):# Any raised exception will mark a plug-in as failedassert instance.data.get("isHero")==True,"%s must be a hero"% instancepyblish.api.register_plugin(CollectCaptainAmerica)pyblish.api.register_plugin(ValidateCaptainAmerica)import pyblish.utilcontext = pyblish.util.publish()
With context at hand, we can now format the results using the results dictionary stored within.
results = context.data.get("results")header ="{:<10}{:<40} -> {}".format("Success", "Plug-in", "Instance")result ="{success:<10}{plugin.__name__:<40} -> {instance}"results ="\n".join(result.format(**r) for r in results)report ="""{header}{line}{results}"""print(report.format(header=header, results=results, line="-"*70))