(self, model, initial=None)
Extends transitions.core.Machine.add_model by applying a custom 'to' function to
            the added model.
Extends transitions.core.Machine.add_model by applying a custom 'to' function to
            the added model.
Extends transitions . core . Machine . add_model by applying a custom to function to the added model .
def add_model(self, model, initial=None):
        """ Extends transitions.core.Machine.add_model by applying a custom 'to' function to
            the added model.
        """
        models = [self if mod is self.self_literal else mod for mod in listify(model)]
        _super(HierarchicalMachine, self).add_model(models, initial=initial)
        initial_name = getattr(models[0], self.model_attribute)
        if hasattr(initial_name, 'name'):
            initial_name = initial_name.name
        # initial states set by add_model or machine might contain initial states themselves.
        if isinstance(initial_name, string_types):
            initial_states = self._resolve_initial(models, initial_name.split(self.state_cls.separator))
        # when initial is set to a (parallel) state, we accept it as it is
        else:
            initial_states = initial_name
        for mod in models:
            self.set_state(initial_states, mod)
            if hasattr(mod, 'to'):
                _LOGGER.warning("%sModel already has a 'to'-method. It will NOT "
                                "be overwritten by NestedMachine", self.name)
            else:
                to_func = partial(self.to_state, mod)
                setattr(mod, 'to', to_func)
def add_model ( self , model , initial = None ) : models = [ self if mod is self . self_literal else mod for mod in listify ( model ) ] _super ( HierarchicalMachine , self ) . add_model ( models , initial = initial ) initial_name = getattr ( models [ 0 ] , self . model_attribute ) if hasattr ( initial_name , 'name' ) : initial_name = initial_name . name # initial states set by add_model or machine might contain initial states themselves. if isinstance ( initial_name , string_types ) : initial_states = self . _resolve_initial ( models , initial_name . split ( self . state_cls . separator ) ) # when initial is set to a (parallel) state, we accept it as it is else : initial_states = initial_name for mod in models : self . set_state ( initial_states , mod ) if hasattr ( mod , 'to' ) : _LOGGER . warning ( "%sModel already has a 'to'-method. It will NOT " "be overwritten by NestedMachine" , self . name ) else : to_func = partial ( self . to_state , mod ) setattr ( mod , 'to' , to_func )