Skip to content

Commit

Permalink
Merge pull request #51 from mottosso/master
Browse files Browse the repository at this point in the history
Enable orders below 0
  • Loading branch information
mottosso authored Jul 3, 2016
2 parents ea39132 + fcba38b commit 3538a2f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyblish_lite/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ def _process(self, plugin, instance=None):

return result

def _run(self, until=-1, on_finished=lambda: None):
def _run(self, until=float("inf"), on_finished=lambda: None):
"""Process current pair and store next pair for next process
Arguments:
until (pyblish.api.Order, optional): Keep fetching next()
until this order, default value -1 means it will run
until there are no more plug-ins.
until this order, default value is infinity.
on_finished (callable, optional): What to do when finishing,
defaults to doing nothing.
Expand All @@ -158,7 +157,8 @@ def on_next():
#
# TODO(marcus): Make this less magical
#
if until != -1 and self.current_pair[0].order > (until + 0.5):
order = self.current_pair[0].order
if order > (until + 0.5):
return util.defer(100, on_finished)

self.about_to_process.emit(*self.current_pair)
Expand Down
33 changes: 33 additions & 0 deletions tests/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,36 @@ def process(self, instance):
ctrl.publish()

assert count["#"] == 111, count


@with_setup(clean)
def test_far_negative_orders():
"""Orders may go below 0"""

count = {"#": 0}

class MyCollector1(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder

class MyCollector2(pyblish.api.ContextPlugin):
order = -1

class MyCollector3(pyblish.api.ContextPlugin):
order = -1000

def process(self, context):
count["#"] += 1

MyCollector1.process = process
MyCollector2.process = process
MyCollector3.process = process

pyblish.api.register_plugin(MyCollector1)
pyblish.api.register_plugin(MyCollector2)
pyblish.api.register_plugin(MyCollector3)

ctrl = control.Controller()
ctrl.reset()

# They all register as Collectors
assert count["#"] == 3, count

0 comments on commit 3538a2f

Please sign in to comment.