]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Use field indexing for format() for clarity.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 30 Oct 2016 18:02:26 +0000 (14:02 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 30 Oct 2016 18:02:26 +0000 (14:02 -0400)
xonstat/models/game.py
xonstat/models/main.py
xonstat/models/map.py
xonstat/models/player.py

index 370d91f8131dc0af0cbf9b491225a45a293c6401..d221cec3a56990a89c6e69a655cb16efe152eff7 100644 (file)
@@ -22,8 +22,7 @@ class Game(object):
         self.winner = winner
 
     def __repr__(self):
-        return ("<Game({}, {}, {}, {})>"
-                .format(self.game_id, self.start_dt, self.game_type_cd, self.server_id))
+        return ("<Game({0.game_id}, {0.start_dt}, {0.game_type_cd}, {0.server_id})>".format(self))
 
     def to_dict(self):
         return {
@@ -50,7 +49,7 @@ class PlayerGameStat(object):
         self.create_dt = create_dt
 
     def __repr__(self):
-        return "<PlayerGameStat({}, {}, {})>".format(self.player_id, self.game_id, self.create_dt)
+        return "<PlayerGameStat({0.player_id}, {0.game_id}, {0.create_dt})>".format(self)
 
     def to_dict(self):
         return {
@@ -102,8 +101,8 @@ class PlayerWeaponStat(object):
         self.frags = 0
 
     def __repr__(self):
-        return ("<PlayerWeaponStat({}, {}, {})>"
-                .format(self.player_weapon_stats_id, self.player_id, self.game_id))
+        return ("<PlayerWeaponStat({0.player_weapon_stats_id}, {0.player_id}, {0.game_id})>"
+                .format(self))
 
     def to_dict(self):
         return {
@@ -129,7 +128,7 @@ class TeamGameStat(object):
         self.create_dt = create_dt
 
     def __repr__(self):
-        return "<TeamGameStat({}, {}, {})>".format(self.team_game_stat_id, self.game_id, self.team)
+        return "<TeamGameStat({0.team_game_stat_id}, {0.game_id}, {0.team})>".format(self)
 
     def to_dict(self):
         return {
@@ -167,7 +166,7 @@ class PlayerGameAnticheat(object):
         self.create_dt = create_dt
 
     def __repr__(self):
-        return "<PlayerGameAnticheat({}, {})>".format(self.key, self.value)
+        return "<PlayerGameAnticheat({0.key}, {0.value})>".format(self)
 
 
 class GameType(object):
@@ -176,7 +175,7 @@ class GameType(object):
     """
 
     def __repr__(self):
-        return "<GameType({}, {}, {})>".format(self.game_type_cd, self.descr, self.active_ind)
+        return "<GameType({0.game_type_cd}, {0.descr}, {0.active_ind})>".format(self)
 
     def to_dict(self):
         return {
@@ -192,7 +191,7 @@ class Weapon(object):
     """
 
     def __repr__(self):
-        return "<Weapon({}, {}, {})>".format(self.weapon_cd, self.descr, self.active_ind)
+        return "<Weapon({0.weapon_cd}, {0.descr}, {0.active_ind})>".format(self)
 
     def to_dict(self):
         return {
index fbb00495077f468eee9bb02b02d3c6a00521dd9d..6eec9ac1254665ca06f0282bd93441603cc5d1b3 100644 (file)
@@ -11,8 +11,8 @@ class SummaryStat(object):
     """
 
     def __repr__(self):
-        return ("<SummaryStat(total_players={}, total_games={}, total_servers={})>"
-                .format(self.total_players, self.total_games, self.total_servers))
+        return ("<SummaryStat(total_players={0.total_players}, total_games={0.total_games}, "
+                "total_servers={0.total_servers})>".format(self))
 
 
 class ActivePlayer(object):
@@ -30,7 +30,7 @@ class ActivePlayer(object):
         return html_colors(self.nick)
 
     def __repr__(self):
-        return "<ActivePlayer({}, {})>".format(self.sort_order, self.player_id)
+        return "<ActivePlayer({0.sort_order}, {0.player_id})>".format(self)
 
 
 class ActiveServer(object):
@@ -45,7 +45,7 @@ class ActiveServer(object):
         self.games = games
 
     def __repr__(self):
-        return "<ActiveServer({}, {})>".format(self.sort_order, self.server_id)
+        return "<ActiveServer({0.sort_order}, {0.server_id})>".format(self)
 
 
 class ActiveMap(object):
@@ -60,4 +60,4 @@ class ActiveMap(object):
         self.games = games
 
     def __repr__(self):
-        return "<ActiveMap({}, {})>".format(self.sort_order, self.map_id)
+        return "<ActiveMap({0.sort_order}, {0.map_id})>".format(self)
index 176e23f8d883e5aed0c09574323ae34f17c5081b..befa34600a0fb6cf8078d576e9240612694c3fd4 100644 (file)
@@ -16,7 +16,7 @@ class Map(object):
         self.name = name
 
     def __repr__(self):
-        return "<Map({}, {}, {})>".format(self.map_id, self.name, self.version)
+        return "<Map({0.map_id}, {0.name}, {0.version})>".format(self)
 
     def to_dict(self):
         return {
index 0fb18d878634592c5e2d8e87dd3ef663b88a4c56..564c18da225ab31d50160cf3bb68952ea664f653 100644 (file)
@@ -50,7 +50,7 @@ class Achievement(object):
     """
 
     def __repr__(self):
-        return "<Achievement({}, {}, {})>".format(self.achievement_cd, self.descr, self.limit)
+        return "<Achievement({0.achievement_cd}, {0.descr}, {0.limit})>".format(self)
 
     def to_dict(self):
         return {
@@ -66,7 +66,7 @@ class PlayerAchievement(object):
     """
 
     def __repr__(self):
-        return "<PlayerAchievement({}, {})>".format(self.player_id, self.achievement_cd)
+        return "<PlayerAchievement({0.player_id}, {0.achievement_cd})>".format(self)
 
     def to_dict(self):
         return {
@@ -85,7 +85,7 @@ class Hashkey(object):
         self.hashkey = hashkey
 
     def __repr__(self):
-        return "<Hashkey({}, {})>".format(self.player_id, self.hashkey)
+        return "<Hashkey({0.player_id}, {0.hashkey})>".format(self)
 
     def to_dict(self):
         return {
@@ -100,7 +100,7 @@ class PlayerNick(object):
     """
 
     def __repr__(self):
-        return "<PlayerNick({}, {})>".format(self.player_id, qfont_decode(self.stripped_nick))
+        return "<PlayerNick({0.player_id}, {0.stripped_nick})>".format(self)
 
     def to_dict(self):
         return {
@@ -122,8 +122,8 @@ class PlayerElo(object):
         self.games = 0
 
     def __repr__(self):
-        return ("<PlayerElo(pid={}, gametype={}, elo={}, games={})>"
-                .format(self.player_id, self.game_type_cd, self.elo, self.games))
+        return ("<PlayerElo(pid={0.player_id}, gametype={0.game_type_cd}, elo={0.elo}, "
+                "games={0.games})>".format(self))
 
     def to_dict(self):
         return {
@@ -146,8 +146,8 @@ class PlayerRank(object):
             return html_colors(self.nick, limit)
 
     def __repr__(self):
-        return ("<PlayerRank(pid={}, gametype={}, rank={})>"
-                .format(self.player_id, self.game_type_cd, self.rank))
+        return ("<PlayerRank(pid={0.player_id}, gametype={0.game_type_cd}, rank={0.rank})>"
+                .format(self))
 
     def to_dict(self):
         return {
@@ -170,8 +170,7 @@ class PlayerCaptime(object):
         self.mod = mod
 
     def __repr__(self):
-        return ("<PlayerCaptime(pid={}, map_id={}, mod={})>"
-                .format(self.player_id, self.map_id, self.mod))
+        return "<PlayerCaptime(pid={0.player_id}, map_id={0.map_id}, mod={0.mod})>".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 "<PlayerGroups({}, {})>".format(self.player_id, self.group_name)
+        return "<PlayerGroups({0.player_id}, {0.group_name})>".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 "<PlayerRank(pid={}, place={}, alt={})>".format(self.player_id, self.place, self.alt)
+        return "<PlayerRank(pid={0.player_id}, place={0.place}, alt={0.alt})>".format(self)