コード例 #1
0
    def _check_input_handlers(cls):
        unbound = [
            signal.name for _, signal in getmembers(cls.Inputs, Input)
            if not signal.handler
        ]
        if unbound:
            raise ValueError("unbound signal(s) in {}: {}".format(
                cls.__name__, ", ".join(unbound)))

        missing_handlers = [
            signal.handler for signal in cls.inputs
            if not hasattr(cls, signal.handler)
        ]
        if missing_handlers:
            raise ValueError("missing handlers in {}: {}".format(
                cls.__name__, ", ".join(missing_handlers)))
コード例 #2
0
    def get_signals(cls, direction, ignore_old_style=False):
        """
        Return a list of `InputSignal` or `OutputSignal` needed for the
        widget description. For old-style signals, the method returns the
        original list. New-style signals are collected into a list.

        Parameters
        ----------
        direction (str): `"inputs"` or `"outputs"`

        Returns
        -------
        list of `InputSignal` or `OutputSignal`
        """
        old_style = cls.__dict__.get(direction, None)
        if old_style and not ignore_old_style:
            return old_style

        signal_class = getattr(cls, direction.title())
        signals = [signal for _, signal in getmembers(signal_class, _Signal)]
        return list(sorted(signals, key=lambda s: s._seq_id))
コード例 #3
0
 def _bind_signals(self):
     for direction, signal_type in (("Inputs", Input), ("Outputs", Output)):
         bound_cls = getattr(self, direction)()
         for name, signal in getmembers(bound_cls, signal_type):
             setattr(bound_cls, name, signal.bound_signal(self))
         setattr(self, direction, bound_cls)
コード例 #4
0
ファイル: signals.py プロジェクト: irgolic/orange-widget-base
 def _bind_outputs(self):
     bound_cls = self.Outputs()
     for name, signal in getmembers(bound_cls, Output):
         setattr(bound_cls, name, signal.bound_signal(self))
     setattr(self, "Outputs", bound_cls)