def register_cmd(self, cmdid, handler): if cmdid in self.__commands: raise KeyError("command %s already exists in %s" % (cmdid, self.__profile)) elif not isinstance(handler, (types.FunctionType, types.MethodType)): raise ValueError("handler is not a function or method") else: self.__commands[cmdid] = handler tml.tml_Profile_Register_Cmd(self.__tml_core.core_handle, self.__profile, cmdid, on_cmd_dispatch_handler, self)
def del_cmd(self, cmdid): del self.__commands[cmdid] tml.tml_Profile_Register_Cmd(self.__tml_core.core_handle, self.__profile, cmdid, None, None)