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
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
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]
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]
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)
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)
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)