Ejemplo n.º 1
0
    def __init__(self, parent=None, invalidate_parent=True, **kwargs):
        self._parent = parent
        self._invalidate_parent = invalidate_parent

        HasTraits.__init__(self)
        self.trait_set(**kwargs)

        self._check_outputs()
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        HasTraits.__init__(self, *args, **kwargs)

        self.namespace = {}

        # we open hdf files and don't necessarily read their contents into memory - these need to be closed when we
        # either delete the recipe, or clear the namespace
        self._open_input_files = []

        self.recipe_changed = dispatch.Signal()
        self.recipe_executed = dispatch.Signal()
Ejemplo n.º 3
0
    def trait_view(self, name=None, view_element=None):
        import traitsui.api as tui
        from six import string_types

        if view_element is None and isinstance(name, string_types):
            try:
                tc = getattr(self, name)

                if isinstance(tc, tui.View):
                    return tc
            except AttributeError:
                pass

        return HasTraits.trait_view(self, name, view_element)
Ejemplo n.º 4
0
    def __init__(self, parent=None, invalidate_parent=True, **kwargs):
        self._parent = parent
        self._invalidate_parent = invalidate_parent

        HasTraits.__init__(self)

        if (parent is not None):
            # make sure that the default output name does not collide with any outputs
            # already in the recipe
            for k, v in self._output_traits.items():
                if v in parent.module_outputs:
                    duplicate_num = 0
                    val = v

                    while (val in parent.module_outputs):
                        # we already have an output of that name in the recipe
                        # increase the subscript until we get a unique value
                        duplicate_num += 1
                        val = v + '_%d' % duplicate_num

                    self.trait_set(**{k: val})

        # if an input matches the default value for an output, our circular reference check will fail, even if we are
        # setting both values to good values in the kwargs (see issue #695). To mitigate, we first set without validation
        # to overwrite any default values which may be modified, and then re-set with validation turned on to catch any
        # circular references in the final values.
        self._initial_set = False
        self.trait_set(
            trait_change_notify=False,
            **kwargs)  #don't notify here - next set will do notification.
        self._initial_set = True

        # validate input and outputs now that output names have been set.
        # for now, just set all the values again to re-trigger validation
        self.trait_set(**kwargs)

        self._check_outputs()
Ejemplo n.º 5
0
 def __init__(self, rule_factories=None, *args, **kwargs):
     if rule_factories is None:
         rule_factories = list()
     self.rule_factories = rule_factories
     HasTraits.__init__(self, *args, **kwargs)