Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pyblish-base/#250 #266

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions pyblish_qml/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def iterator(self, plugins, context):
"ordersWithError": set()
}

for plug, instance in iterator(plugins, context):
for plug, instance in pyblish.logic.Iterator(plugins, context):

state["nextOrder"] = plug.order

Expand Down Expand Up @@ -571,6 +571,11 @@ def __toggle_item(self, model, index):
new_value=new_value,
old_value=old_value)

# Update the plugin's active state so it processes correctly (#218)
plugin = next(plugin for plugin in self.host.cached_discover if
plugin.id == item.id)
plugin.active = new_value

if item.itemType == 'instance':
self.host.emit("instanceToggled",
instance=item.id,
Expand Down Expand Up @@ -687,12 +692,23 @@ def reset(self):
def on_finished(plugins, context):
# Compute compatibility
for plugin in self.data["models"]["item"].plugins:

if plugin.instanceEnabled:
instances = pyblish.logic.instances_by_plugin(context,
plugin)
plugin.compatibleInstances = list(i.id for i in instances)
required = pyblish.logic.instances_by_plugin(context,
plugin)
else:
plugin.compatibleInstances = [context.id]
# A ContextPlugin without wildcard is only compatible
# when instance is present with correct family, see issue:
# pyblish-base/#250
# todo: introduce backwards compatibility
has_wildcard = "*" in plugin.families
if has_wildcard:
required = [context]
else:
required = pyblish.logic.instances_by_plugin(context,
plugin)

plugin.compatibleInstances = [i.id for i in required]

self.data["models"]["item"].reorder(context)

Expand Down Expand Up @@ -1023,27 +1039,3 @@ def on_finished():

# Reset state
util.async(lambda: next(iterator), callback=on_next)


def iterator(plugins, context):
"""An iterator for plug-in and instance pairs"""
test = pyblish.logic.registered_test()
state = {
"nextOrder": None,
"ordersWithError": set()
}

for plugin in plugins:
state["nextOrder"] = plugin.order

message = test(**state)
if message:
raise StopIteration("Stopped due to %s" % message)

instances = pyblish.api.instances_by_plugin(context, plugin)
if plugin.__instanceEnabled__:
for instance in instances:
yield plugin, instance

else:
yield plugin, None