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)))
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))
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)
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)