本文整理汇总了Python中emitter.Emitter类的典型用法代码示例。如果您正苦于以下问题:Python Emitter类的具体用法?Python Emitter怎么用?Python Emitter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Emitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on__9
def test_on__9():
"""
Returns True when event has been successfully registered.
"""
emitter = Emitter()
assert emitter.on("event", callable) is True
assert callable in emitter.listeners("event")
示例2: test_events__4
def test_events__4():
"""
True event can be retrieved.
"""
emitter = Emitter()
emitter.on(True, callable)
assert True in emitter.events()
示例3: __init__
class Reaper:
def __init__(self, args):
self.args = args
self.start = clock()
self.emitter = Emitter()
self.neural_network = NeuralNetwork((Vitals.FIRST_LAYER, Vitals.SECOND_LAYER, Vitals.OUTPUT_LAYER), learning_rate=Vitals.LEARNING_RATE, momentum=Vitals.MOMENTUM_RATE)
self.conscience = Conscience()
self.interpreter = Interpreter(self.emitter)
print "Kernel bootstrap completed in %.2f seconds" % (clock() - self.start)
def cl_start(self):
print u'cl_start func'
def slack_start(self):
from ports.slack import Slack
slack = Slack('xoxb-5033078835-U4Jcw2kkaebWWsuUUtyJNNaS', self.emitter)
# Register skills
self.emitter.register('on_message', self.interpreter.learn)
self.emitter.register('send_message', slack.send)
# Bootstrap
slack.start()
def rpi_start(self):
print u'rpi_start func'
示例4: test_events__3
def test_events__3():
"""
False event can be retrieved.
"""
emitter = Emitter()
emitter.on(False, callable)
assert False in emitter.events()
示例5: test_events__5
def test_events__5():
"""
Should not return the original object, but a copy.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.events() is not emitter.events()
示例6: test_off__12
def test_off__12():
"""
Returns True if the specified listener has been detached.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.off("event", callable) is True
示例7: test_off__10
def test_off__10():
"""
Returns True if the specified event has been deleted.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.off("event") is True
示例8: test_listeners__4
def test_listeners__4():
"""
Get the listeners for the False event.
"""
emitter = Emitter()
emitter.on(False, callable)
assert callable in emitter.listeners(False)
示例9: test_listeners__6
def test_listeners__6():
"""
Should not return the original object, but a copy.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.listeners("event") is not emitter.listeners("event")
示例10: test_emit__9
def test_emit__9():
"""
Emitting None event returns False.
"""
emitter = Emitter()
assert emitter.emit(None) is False
示例11: test_listeners__5
def test_listeners__5():
"""
Get the listeners for the True event.
"""
emitter = Emitter()
emitter.on(True, callable)
assert callable in emitter.listeners(True)
示例12: test_off__11
def test_off__11():
"""
Returns True if trying to detach a non-existent listener.
"""
emitter = Emitter()
emitter.on("event", callable)
assert emitter.off("event", bool) is True
示例13: test_emit__4
def test_emit__4():
"""
Returns False when emitting a non-existent event.
"""
emitter = Emitter()
result = emitter.emit("event")
assert result is False
示例14: test_listeners__1
def test_listeners__1():
"""
Returns an empty list when asking for an unknown event.
"""
emitter = Emitter()
assert isinstance(emitter.listeners(""), list)
assert emitter.listeners("") == []
示例15: test_on__3
def test_on__3():
"""
False is a valid event.
"""
emitter = Emitter()
emitter.on(False, callable)
assert False in emitter.events()