def __init__(self, left, right, op): from glue.core.data import ComponentID self._left = left self._right = right self._op = op from_ = [] if isinstance(left, ComponentID): from_.append(left) elif isinstance(left, ComponentLink): from_.extend(left.get_from_ids()) elif not isinstance(left, numbers.Number): raise TypeError("Cannot create BinaryComponentLink using %s" % left) if isinstance(right, ComponentID): from_.append(right) elif isinstance(right, ComponentLink): from_.extend(right.get_from_ids()) elif not isinstance(right, numbers.Number): raise TypeError("Cannot create BinaryComponentLink using %s" % right) to = ComponentID("") super(BinaryComponentLink, self).__init__(from_, to, null)
def _toid(arg): """Coerce the input to a ComponentID, if possible""" if isinstance(arg, ComponentID): return arg elif isinstance(arg, str): return ComponentID(arg) else: raise TypeError('Cannot be cast to a ComponentID: %s' % arg)
def _load_component_id(rec, context): return ComponentID(rec['label'], rec['hidden'])