Ejemplo n.º 1
0
class ACompound:
    def __init__( self, eventDict ):
        self._values = ParameterSet( eventDict["params"] )
        self._events = None
        self._state = None
        # do we want to reevaluate self on any of our events even if not changed
        self._alwaysReDo = eventDict.has_key( "redo" ) and (eventDict["redo"] == 'yes')

        if eventDict.has_key( "newEvent" ):
            if isinstance( eventDict["newEvent"], list ):
                self._events = eventDict["newEvent"]
            else:
                self._events = list()
                self._events.append( eventDict["newEvent"] )
            # TODO Validate newEvent data structure, suggest utility helper so can be used elsewhere
        if eventDict.has_key( "newState" ):
            if isinstance( eventDict["newState"], list ):
                self._state = eventDict["newState"]
            else:
                self._state = list()
                self._state.append( eventDict["newState"] )

    def uses( self, name ):
        """ quick check on whether a change means we should be scanned """
        return self._values.uses( name )

    def match( self, allValues ):
        """ allValues is a complete dictionary of name value pairs """
        return self._values.match( allValues )

    def keys(self):
        return self._values.keys()

    def events(self):
        return self._events

    def state(self):
        return self._state

    def __str__(self):
        return "ParameterSet %s Events %s StateUpdates %s" % ( self._values, self._events, self._state )
Ejemplo n.º 2
0
    def __init__( self, eventDict ):
        self._values = ParameterSet( eventDict["params"] )
        self._events = None
        self._state = None
        # do we want to reevaluate self on any of our events even if not changed
        self._alwaysReDo = eventDict.has_key( "redo" ) and (eventDict["redo"] == 'yes')

        if eventDict.has_key( "newEvent" ):
            if isinstance( eventDict["newEvent"], list ):
                self._events = eventDict["newEvent"]
            else:
                self._events = list()
                self._events.append( eventDict["newEvent"] )
            # TODO Validate newEvent data structure, suggest utility helper so can be used elsewhere
        if eventDict.has_key( "newState" ):
            if isinstance( eventDict["newState"], list ):
                self._state = eventDict["newState"]
            else:
                self._state = list()
                self._state.append( eventDict["newState"] )