##// END OF EJS Templates
Merge pull request #1932 from takluyver/i1916...
Thomas Kluyver -
r7521:b6137d28 merge
parent child Browse files
Show More
@@ -41,7 +41,7 b' somewhere in your configuration files or ipython command line.'
41 # the file COPYING, distributed as part of this software.
41 # the file COPYING, distributed as part of this software.
42 #*****************************************************************************
42 #*****************************************************************************
43
43
44 import os, bisect
44 import os
45 import subprocess
45 import subprocess
46 import sys
46 import sys
47
47
@@ -146,7 +146,8 b' class CommandChainDispatcher:'
146
146
147 def add(self, func, priority=0):
147 def add(self, func, priority=0):
148 """ Add a func to the cmd chain with given priority """
148 """ Add a func to the cmd chain with given priority """
149 bisect.insort(self.chain,(priority,func))
149 self.chain.append((priority, func))
150 self.chain.sort(key=lambda x: x[0])
150
151
151 def __iter__(self):
152 def __iter__(self):
152 """ Return all objects in chain.
153 """ Return all objects in chain.
@@ -73,3 +73,9 b' def test_command_chain_dispatcher_fofo():'
73 nt.assert_true(okay1.called)
73 nt.assert_true(okay1.called)
74 nt.assert_false(fail2.called)
74 nt.assert_false(fail2.called)
75 nt.assert_false(okay2.called)
75 nt.assert_false(okay2.called)
76
77 def test_command_chain_dispatcher_eq_priority():
78 okay1 = Okay(u'okay1')
79 okay2 = Okay(u'okay2')
80 dp = CommandChainDispatcher([(1, okay1)])
81 dp.add(okay2, 1)
General Comments 0
You need to be logged in to leave comments. Login now