load the configuration

def load(self, config):
        """load the configuration"""
        self.config = config
        
        if 'start' not in self.config:
            raise ParseError('missing start entry')
        if 'states' not in self.config:
            raise ParseError('missing states entry')
        if 'transitions' not in self.config:
            raise ParseError('missing transitions entry')

        for state, val in self.config['states'].iteritems():
            state = State(state)
            state.entering = Action.load(val.get('entering'))
            state.leaving = Action.load(val.get('leaving'))
            
            self.states.add(state)
            
        self.start = self.states[self.config['start']]
        
        for transition, val in self.config['transitions'].iteritems():
            if '->' in transition:
                # from->to
                lft, rgt = transition.split('->')
                if lft == '*':
                    sfroms = self.states.keys()
                else:
                    sfroms = lft.split(',')
                if rgt == '*':
                    stos = self.states.keys()
                else:
                    stos = rgt.split(',')
                pairs = ((f, t) for f in sfroms for t in stos)
            else:
                # self transition 'from1,from2' = from1->from1, from2->from2
                if transition == '*':
                    ss = self.states.keys()
                else:
                    ss = transition.split(',')
                pairs = ((x, x) for x in ss)
                
            for sfrom, sto in pairs:
                if sfrom not in self.states:
                    raise ParseError("Could find state %r" % sfrom)
                if sto not in self.states:
                    raise ParseError("Could find state %r" % sto)

                s_from = self.states[sfrom]
                s_to = self.states[sto]
                
                if not isinstance(val, list):
                    val = [val]
                for v in val:
                    when = v['when']
                    actions = Action.load(v.get('actions'))
                    transition = Transition(s_from, s_to, Condition(when), actions)
                    s_from.transitions.append(transition)