pyblish / pyblish-base

Pyblish base library - see https://github.com/pyblish/pyblish for details.
Other
127 stars 59 forks source link

Verbose option to `util.publish` #299

Open mottosso opened 8 years ago

mottosso commented 8 years ago

Goal

Simplify debugging by outputting more information on demand.

Interface

from pyblish import util
util.publish()

Outputs

Here's some tips for those interested in giving this a go.

The util.publish() function is more or less a for-loop.

for plugin in plugins:
  for instance in context:
    plugin.process(instance)

Granted, this is somewhat simplified when you take into consideration that some plug-ins only apply to some instances based on criteria such as their families. But beyond that, it's a loop.

To output more data from this function, what you would need to do is somehow print or log messages from within this loop.

for plugin in plugins:
  for instance in context:
    result = plugin.process(instance)
    print("{plugin} ran with error: {error}".format(**result))

This, along with any other information you can think of, must then be if-statemented to only trigger when the user passes verbose=True to the function.

def publish(..., verbose=False):
    if verbose:
      print("Verbose information")

Good luck!