def get_servers_data(self, game: str) -> dict: if game in ("", None): raise ValueError(i18n._("Please specify a valid game id.")) with self.__game_table as game_table: servers_data = helpers.deepcopy(game_table[game]["servers"]) return servers_data
def get_servers_data(self, game: str) -> dict: if game in ('', None): raise ValueError(i18n._('Please specify a valid game id.')) with self.__game_table as game_table: servers_data = helpers.deepcopy(game_table[game]["servers"]) return servers_data
def get_game_table_copy(self): """ Returns a deep copy of the Game Table. It is the slowest accessor method. Please try to query for specific information. """ with self.__game_table as game_table: game_table_copy = helpers.deepcopy(game_table) return game_table_copy
def fill_server_list_model(self, server_table): """Fill the server view""" view_table = helpers.deepcopy(server_table) model = self.gtk_widgets["server-list-model"] model_append = model.append model_format = self.server_list_model_format game_icons = self.game_icons flag_icons = self.flag_icons # Clears the model # UGLY HACK! # Workaround for chaotic TreeViewSelection on ListModel erase host_selection = gtk_helpers.get_widget_value( self.gtk_widgets["server-connect-host"]) game_selection = gtk_helpers.get_widget_value( self.gtk_widgets["server-connect-game"]) model.clear() gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"], host_selection) gtk_helpers.set_widget_value( self.gtk_widgets["server-connect-game"], game_selection, treeview_colnum=self.game_list_model_format.index("game_id")) # Goodies for GUI for entry in view_table: game_id = entry.get("game_id") country = entry.get("country") # Game icon entry["game_icon"] = game_icons.get(game_id) # Lock icon if entry["password"] is True: entry["password_icon"] = "network-wireless-encrypted-symbolic" else: entry["password_icon"] = None if entry["secure"] is True: entry["secure_icon"] = "security-high-symbolic" else: entry["secure_icon"] = None # Country flags entry["country_icon"] = flag_icons.get(country) # Filtering stuff entry["full"] = entry["player_count"] >= entry["player_limit"] entry["empty"] = entry["player_count"] == 0 view_table = helpers.sort_dict_table(view_table, "ping") server_list = helpers.dict_to_list(view_table, model_format) for entry in server_list: model_append(entry)
def get_query_status(self, game: str): if game in ("", None): raise ValueError(i18n._("Invalid game specified.")) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError(i18n._("Game not found: %(game)s") % {"game": game}) query_status = helpers.deepcopy(game_entry["query-status"]) return query_status
def fill_server_list_model(self, server_table): """Fill the server view""" view_table = helpers.deepcopy(server_table) model = self.gtk_widgets["server-list-model"] model_append = model.append model_format = self.server_list_model_format game_icons = self.game_icons flag_icons = self.flag_icons # Clears the model # UGLY HACK! # Workaround for chaotic TreeViewSelection on ListModel erase host_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-host"]) game_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-game"]) model.clear() gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"], host_selection) gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-game"], game_selection, treeview_colnum=self.game_list_model_format.index("game_id")) # Goodies for GUI for entry in view_table: game_id = entry.get("game_id") country = entry.get("country") # Game icon entry["game_icon"] = game_icons.get(game_id) # Lock icon if entry["password"] is True: entry["password_icon"] = "network-wireless-encrypted-symbolic" else: entry["password_icon"] = None if entry["secure"] is True: entry["secure_icon"] = "security-high-symbolic" else: entry["secure_icon"] = None # Country flags entry["country_icon"] = flag_icons.get(country) # Filtering stuff entry["full"] = entry["player_count"] >= entry["player_limit"] entry["empty"] = entry["player_count"] == 0 view_table = helpers.sort_dict_table(view_table, "ping") server_list = helpers.dict_to_list(view_table, model_format) for entry in server_list: model_append(entry)
def get_query_status(self, game: str): if game in ('', None): raise ValueError(i18n._('Invalid game specified.')) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError( i18n._('Game not found: %(game)s') % {'game': game}) query_status = helpers.deepcopy(game_entry["query-status"]) return query_status
def get_game_info(self, game): """ Returns information about the specified game. """ if game in ("", None): raise ValueError(i18n._("Invalid game specified.")) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError(i18n._("Game not found: %(game)s") % {"game": game}) game_info = helpers.deepcopy(game_entry["info"]) return game_info
def get_game_info(self, game): """ Returns information about the specified game. """ if game in ('', None): raise ValueError(i18n._('Invalid game specified.')) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError( i18n._('Game not found: %(game)s') % {'game': game}) game_info = helpers.deepcopy(game_entry["info"]) return game_info
def set_server_info(self, game: str, host: str, data) -> None: faulty_param = None if game in ("", None): faulty_param = i18n._("game id") elif host in ("", None): faulty_param = i18n._("hostname") elif isinstance(data, dict) is False: faulty_param = i18n._("server data") if faulty_param is not None: raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param}) with self.__game_table as game_table: server_entry_index = game_table[helpers.search_dict_table(helpers.deepcopy(game_table), "host", host)] if server_entry_index is None: self.append_server_info(game, data) else: game_table[server_entry_index] = data
def get_server_info(self, game: str, host: str) -> dict: faulty_param = None if game in ("", None): faulty_param = i18n._("game id") elif host in ("", None): faulty_param = i18n._("hostname") if faulty_param is not None: raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param}) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError(i18n._("Game not found: %(game)s") % {"game": game}) server_table = helpers.deepcopy(game_entry["servers"]) server_entry = server_table[helpers.search_dict_table(server_table, "host", host)] return server_entry
def set_server_info(self, game: str, host: str, data) -> None: faulty_param = None if game in ('', None): faulty_param = i18n._('game id') elif host in ('', None): faulty_param = i18n._('hostname') elif isinstance(data, dict) is False: faulty_param = i18n._('server data') if faulty_param is not None: raise ValueError( i18n._('Invalid %(param)s specified.') % {'param': param}) with self.__game_table as game_table: server_entry_index = game_table[helpers.search_dict_table( helpers.deepcopy(game_table), "host", host)] if server_entry_index is None: self.append_server_info(game, data) else: game_table[server_entry_index] = data
def get_server_info(self, game: str, host: str) -> dict: faulty_param = None if game in ('', None): faulty_param = i18n._('game id') elif host in ('', None): faulty_param = i18n._('hostname') if faulty_param is not None: raise ValueError( i18n._('Invalid %(param)s specified.') % {'param': param}) with self.__game_table as game_table: try: game_entry = game_table[game] except KeyError: raise ValueError( i18n._('Game not found: %(game)s') % {'game': game}) server_table = helpers.deepcopy(game_entry["servers"]) server_entry = server_table[helpers.search_dict_table( server_table, "host", host)] return server_entry