From acf828ab53fd35b5d2fd39091b3314f4e376289e Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 30 Oct 2016 14:02:26 -0400 Subject: [PATCH] Use field indexing for format() for clarity. --- xonstat/models/game.py | 17 ++++++++--------- xonstat/models/main.py | 10 +++++----- xonstat/models/map.py | 2 +- xonstat/models/player.py | 23 +++++++++++------------ 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/xonstat/models/game.py b/xonstat/models/game.py index 370d91f..d221cec 100644 --- a/xonstat/models/game.py +++ b/xonstat/models/game.py @@ -22,8 +22,7 @@ class Game(object): self.winner = winner def __repr__(self): - return ("" - .format(self.game_id, self.start_dt, self.game_type_cd, self.server_id)) + return ("".format(self)) def to_dict(self): return { @@ -50,7 +49,7 @@ class PlayerGameStat(object): self.create_dt = create_dt def __repr__(self): - return "".format(self.player_id, self.game_id, self.create_dt) + return "".format(self) def to_dict(self): return { @@ -102,8 +101,8 @@ class PlayerWeaponStat(object): self.frags = 0 def __repr__(self): - return ("" - .format(self.player_weapon_stats_id, self.player_id, self.game_id)) + return ("" + .format(self)) def to_dict(self): return { @@ -129,7 +128,7 @@ class TeamGameStat(object): self.create_dt = create_dt def __repr__(self): - return "".format(self.team_game_stat_id, self.game_id, self.team) + return "".format(self) def to_dict(self): return { @@ -167,7 +166,7 @@ class PlayerGameAnticheat(object): self.create_dt = create_dt def __repr__(self): - return "".format(self.key, self.value) + return "".format(self) class GameType(object): @@ -176,7 +175,7 @@ class GameType(object): """ def __repr__(self): - return "".format(self.game_type_cd, self.descr, self.active_ind) + return "".format(self) def to_dict(self): return { @@ -192,7 +191,7 @@ class Weapon(object): """ def __repr__(self): - return "".format(self.weapon_cd, self.descr, self.active_ind) + return "".format(self) def to_dict(self): return { diff --git a/xonstat/models/main.py b/xonstat/models/main.py index fbb0049..6eec9ac 100644 --- a/xonstat/models/main.py +++ b/xonstat/models/main.py @@ -11,8 +11,8 @@ class SummaryStat(object): """ def __repr__(self): - return ("" - .format(self.total_players, self.total_games, self.total_servers)) + return ("".format(self)) class ActivePlayer(object): @@ -30,7 +30,7 @@ class ActivePlayer(object): return html_colors(self.nick) def __repr__(self): - return "".format(self.sort_order, self.player_id) + return "".format(self) class ActiveServer(object): @@ -45,7 +45,7 @@ class ActiveServer(object): self.games = games def __repr__(self): - return "".format(self.sort_order, self.server_id) + return "".format(self) class ActiveMap(object): @@ -60,4 +60,4 @@ class ActiveMap(object): self.games = games def __repr__(self): - return "".format(self.sort_order, self.map_id) + return "".format(self) diff --git a/xonstat/models/map.py b/xonstat/models/map.py index 176e23f..befa346 100644 --- a/xonstat/models/map.py +++ b/xonstat/models/map.py @@ -16,7 +16,7 @@ class Map(object): self.name = name def __repr__(self): - return "".format(self.map_id, self.name, self.version) + return "".format(self) def to_dict(self): return { diff --git a/xonstat/models/player.py b/xonstat/models/player.py index 0fb18d8..564c18d 100644 --- a/xonstat/models/player.py +++ b/xonstat/models/player.py @@ -50,7 +50,7 @@ class Achievement(object): """ def __repr__(self): - return "".format(self.achievement_cd, self.descr, self.limit) + return "".format(self) def to_dict(self): return { @@ -66,7 +66,7 @@ class PlayerAchievement(object): """ def __repr__(self): - return "".format(self.player_id, self.achievement_cd) + return "".format(self) def to_dict(self): return { @@ -85,7 +85,7 @@ class Hashkey(object): self.hashkey = hashkey def __repr__(self): - return "".format(self.player_id, self.hashkey) + return "".format(self) def to_dict(self): return { @@ -100,7 +100,7 @@ class PlayerNick(object): """ def __repr__(self): - return "".format(self.player_id, qfont_decode(self.stripped_nick)) + return "".format(self) def to_dict(self): return { @@ -122,8 +122,8 @@ class PlayerElo(object): self.games = 0 def __repr__(self): - return ("" - .format(self.player_id, self.game_type_cd, self.elo, self.games)) + return ("".format(self)) def to_dict(self): return { @@ -146,8 +146,8 @@ class PlayerRank(object): return html_colors(self.nick, limit) def __repr__(self): - return ("" - .format(self.player_id, self.game_type_cd, self.rank)) + return ("" + .format(self)) def to_dict(self): return { @@ -170,8 +170,7 @@ class PlayerCaptime(object): self.mod = mod def __repr__(self): - return ("" - .format(self.player_id, self.map_id, self.mod)) + return "".format(self) def fuzzy_date(self): return pretty_date(self.create_dt) @@ -190,7 +189,7 @@ class PlayerGroups(object): self.group_name = group_name def __repr__(self): - return "".format(self.player_id, self.group_name) + return "".format(self) # TODO: determine if this is a real model (it is very similar to PlayerCaptime from above) @@ -230,4 +229,4 @@ class PlayerMedal(object): """ def __repr__(self): - return "".format(self.player_id, self.place, self.alt) + return "".format(self) -- 2.39.2