当前位置: 首页>>代码示例>>Python>>正文


Python smokesignal.on函数代码示例

本文整理汇总了Python中smokesignal.on函数的典型用法代码示例。如果您正苦于以下问题:Python on函数的具体用法?Python on怎么用?Python on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了on函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, name, k=10):
        self.k = k
        self.fname = _timestamped_filename(
            "%s-precision-at-%d" % (name, self.k))

        smokesignal.on('evaluation_finished', self.on_evaluation_finished)
        super(PrecisionAtKListener, self).__init__()
开发者ID:TythonLee,项目名称:linkpred,代码行数:7,代码来源:listeners.py

示例2: test_emit_with_callback_args

    def test_emit_with_callback_args(self):
        # Register first
        smokesignal.on('foo', self.mock_callback)
        assert smokesignal.responds_to(self.mock_callback, 'foo')

        smokesignal.emit('foo', 1, 2, 3, foo='bar')
        assert self.mock_callback.called_with(1, 2, 3, foo='bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:7,代码来源:tests.py

示例3: test_on_creates_responds_to_fn

    def test_on_creates_responds_to_fn(self):
        # Registering a callback should create partials to smokesignal
        # methods for later user
        smokesignal.on('foo', self.callback)

        assert hasattr(self.callback, 'responds_to')
        assert self.callback.responds_to('foo')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:7,代码来源:tests.py

示例4: test_clear_many

 def test_clear_many(self):
     smokesignal.on(('foo', 'bar', 'baz'), self.fn)
     smokesignal.clear('foo', 'bar')
     assert smokesignal.receivers == {
         'foo': set(),
         'bar': set(),
         'baz': set([self.fn]),
     }
开发者ID:Brightmd,项目名称:smokesignal,代码行数:8,代码来源:tests.py

示例5: test_clear_all

    def test_clear_all(self):
        smokesignal.on(('foo', 'bar'), self.callback)
        assert len(smokesignal._receivers['foo']) == 1
        assert len(smokesignal._receivers['bar']) == 1

        smokesignal.clear_all()
        assert len(smokesignal._receivers['foo']) == 0
        assert len(smokesignal._receivers['bar']) == 0
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py

示例6: test_on_creates_signals_fn

    def test_on_creates_signals_fn(self):
        # Registering a callback should create partials to smokesignal
        # methods for later user
        smokesignal.on(('foo', 'bar'), self.callback)

        assert hasattr(self.callback, 'signals')
        assert 'foo' in self.callback.signals()
        assert 'bar' in self.callback.signals()
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py

示例7: test_on_registers_many

    def test_on_registers_many(self):
        assert len(smokesignal._receivers['foo']) == 0
        assert len(smokesignal._receivers['bar']) == 0

        smokesignal.on(('foo', 'bar'), self.callback)

        assert len(smokesignal._receivers['foo']) == 1
        assert len(smokesignal._receivers['bar']) == 1
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py

示例8: test_disconnect

    def test_disconnect(self):
        # Register first
        smokesignal.on(('foo', 'bar'), self.callback)
        assert smokesignal.responds_to(self.callback, 'foo')
        assert smokesignal.responds_to(self.callback, 'bar')

        smokesignal.disconnect(self.callback)
        assert not smokesignal.responds_to(self.callback, 'foo')
        assert not smokesignal.responds_to(self.callback, 'bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:9,代码来源:tests.py

示例9: test_on_registers_many

    def test_on_registers_many(self):
        assert smokesignal.receivers == {}

        smokesignal.on(('foo', 'bar'), self.fn)

        assert smokesignal.receivers == {
            'foo': set([self.fn]),
            'bar': set([self.fn]),
        }
开发者ID:Brightmd,项目名称:smokesignal,代码行数:9,代码来源:tests.py

示例10: __init__

    def __init__(self):
        if not hasattr(self, 'plugins'):
            self.plugins = {}

        if not hasattr(self, 'enabled_plugins'):
            # Enabled plugins is a dict: channel -> set()
            self.enabled_plugins = defaultdict(lambda: set(getattr(settings, 'ENABLED_PLUGINS', [])))

        smokesignal.on('started', self.load)
开发者ID:michaelorr,项目名称:helga,代码行数:9,代码来源:core.py

示例11: test_on_decorator_max_calls_as_arg

    def test_on_decorator_max_calls_as_arg(self):
        # Register first - like a decorator
        smokesignal.on('foo', 3)(self.fn)

        # Call a bunch of times
        for x in range(10):
            smokesignal.emit('foo')

        assert self.fn.call_count == 3
开发者ID:Brightmd,项目名称:smokesignal,代码行数:9,代码来源:tests.py

示例12: test_disconnect_from_removes_all

    def test_disconnect_from_removes_all(self):
        # Register first
        smokesignal.on(('foo', 'bar'), self.callback)
        assert smokesignal.responds_to(self.callback, 'foo')
        assert smokesignal.responds_to(self.callback, 'bar')

        # Remove it
        smokesignal.disconnect_from(self.callback, ('foo', 'bar'))
        assert not smokesignal.responds_to(self.callback, 'foo')
        assert not smokesignal.responds_to(self.callback, 'bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:10,代码来源:tests.py

示例13: test_on_max_calls

    def test_on_max_calls(self):
        # Register first
        smokesignal.on('foo', self.fn, max_calls=3)

        # Call a bunch of times
        for x in range(10):
            smokesignal.emit('foo')

        assert self.fn.call_count == 3
        assert smokesignal.receivers['foo'] == set()
开发者ID:Brightmd,项目名称:smokesignal,代码行数:10,代码来源:tests.py

示例14: test_disconnect_from_removes_only_one

    def test_disconnect_from_removes_only_one(self):
        # Register first
        smokesignal.on(('foo', 'bar'), self.fn)
        assert smokesignal.responds_to(self.fn, 'foo')
        assert smokesignal.responds_to(self.fn, 'bar')

        # Remove it
        smokesignal.disconnect_from(self.fn, 'foo')
        assert not smokesignal.responds_to(self.fn, 'foo')
        assert smokesignal.responds_to(self.fn, 'bar')
开发者ID:Brightmd,项目名称:smokesignal,代码行数:10,代码来源:tests.py

示例15: __init__

            def __init__(self):
                # Preferred way
                smokesignal.on('foo', self.foo)

                # Old way
                @smokesignal.on('foo')
                def _bar():
                    self.bar()

                self.foo_count = 0
                self.bar_count = 0
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:11,代码来源:tests.py


注:本文中的smokesignal.on函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。