예제 #1
0
    def remove_callback(self, callback, dest):
        """Remove a specific function from a specific callback.  Function object must be the one added before."""
        if callback not in self:
            raise UnknownCallbackError("Callback \"%s\" does not exists." % callback)
        
        if self[callback] is None or dest not in self[callback]:
            raise UnknownCallbackError("Function not registered for callback \"%s\"." % callback)

        self[callback].remove(dest)
        if len(self[callback]) == 0:
            self[callback] = None
예제 #2
0
    def reset_callback(self, callback):
        """remove functions for a defined callback"""
        if callback not in self:
            raise UnknownCallbackError("Callback \"%s\" does not exists." %
                                       callback)

        self[callback] = None
예제 #3
0
    def get_callback(self, callback):
        """Get the functions assigned to a callback as a list. Return None if no callback defined"""
        if callback not in self:
            raise UnknownCallbackError("Callback \"%s\" does not exists." %
                                       callback)

        return self[callback]
예제 #4
0
    def set_callback(self, callback, dest):
        """Define the function to call for a specific callback.  Suppress any axisting callback function"""
        if callback not in self:
            raise UnknownCallbackError("Callback \"%s\" does not exists." %
                                       callback)

        self[callback] = [dest]
예제 #5
0
 def add_callback(self, callback, dest):
     """Add the function to call for a specific callback."""
     if callback not in self:
         raise UnknownCallbackError("Callback \"%s\" does not exists." % callback)
     
     if self[callback] is None:
         self[callback] = list()
     self[callback].append(dest)
예제 #6
0
 def call_callback(self, callback, *pos_parameters):
     """Call all the registered function for a specific callback."""
     if callback not in self:
         raise UnknownCallbackError("Callback \"%s\" does not exists." % callback)
     
     if self[callback]:
         for func in self[callback]:
             func(*pos_parameters)
예제 #7
0
 def call_callback(self, callback, *pos_parameters):
     """Call all the registered function for a specific callback."""
     if callback not in self:
         raise UnknownCallbackError("Callback \"%s\" does not exists." % callback)
     
     if self[callback]:
         for func in self[callback]:
             if callback is PYMUMBLE_CLBK_TEXTMESSAGERECEIVED:
                 thr = threading.Thread(target=func, args=pos_parameters)
                 thr.start()
             else:
                 func(*pos_parameters)