Some code format changes for better readability
authornyov <nyov@nexnode.net>
Tue, 5 Jun 2012 02:02:27 +0000 (04:02 +0200)
committernyov <nyov@nexnode.net>
Tue, 5 Jun 2012 02:02:27 +0000 (04:02 +0200)
xonstat/__init__.py
xonstat/models.py
xonstat/views/__init__.py

index 5a164ef4c7dbcefbf0847ca1cd7ef26e2a412a23..2e45a0853d4d47e1815a28f8c1e3a6a37ed44476 100644 (file)
@@ -2,7 +2,7 @@ import sqlahelper
 from pyramid.config import Configurator
 from sqlalchemy import engine_from_config
 from xonstat.models import initialize_db
-from xonstat.views import * 
+from xonstat.views import *
 
 def main(global_config, **settings):
     """ This function returns a Pyramid WSGI application.
@@ -20,74 +20,58 @@ def main(global_config, **settings):
 
     # ROOT ROUTE
     config.add_route("main_index", "/")
-    config.add_view(main_index, route_name="main_index",
-        renderer="main_index.mako")
+    config.add_view(main_index, route_name="main_index", renderer="main_index.mako")
 
     # MAIN SUBMISSION ROUTE
     config.add_route("stats_submit", "stats/submit")
     config.add_view(stats_submit, route_name="stats_submit")
 
     # PLAYER ROUTES
-    config.add_route("player_game_index",
-            "/player/{player_id:\d+}/games")
-    config.add_view(player_game_index, route_name="player_game_index",
-        renderer="player_game_index.mako")
+    config.add_route("player_game_index", "/player/{player_id:\d+}/games")
+    config.add_view(player_game_index, route_name="player_game_index", renderer="player_game_index.mako")
 
     config.add_route("player_index", "/players")
-    config.add_view(player_index, route_name="player_index",
-        renderer="player_index.mako")
+    config.add_view(player_index, route_name="player_index", renderer="player_index.mako")
 
     config.add_route("player_info", "/player/{id:\d+}")
-    config.add_view(player_info, route_name="player_info",
-        renderer="player_info.mako")
+    config.add_view(player_info, route_name="player_info", renderer="player_info.mako")
 
-    config.add_route("player_accuracy", "/player/{id:\d+}/accuracy")
-    config.add_view(player_accuracy_json, route_name="player_accuracy",
-        renderer="json")
+    config.add_route("player_accuracy",      "/player/{id:\d+}/accuracy")
+    config.add_route("player_accuracy_json", "/player/{id:\d+}/accuracy.json")
+    config.add_view(player_accuracy_json, route_name="player_accuracy",      renderer="json")
+    config.add_view(player_accuracy_json, route_name="player_accuracy_json", renderer="json")
 
     # GAME ROUTES
     config.add_route("game_index", "/games")
-    config.add_view(game_index, route_name="game_index",
-        renderer="game_index.mako")
+    config.add_view(game_index, route_name="game_index", renderer="game_index.mako")
 
     config.add_route("game_info", "/game/{id:\d+}")
-    config.add_view(game_info, route_name="game_info",
-        renderer="game_info.mako")
+    config.add_view(game_info, route_name="game_info", renderer="game_info.mako")
 
     config.add_route("rank_index", "/ranks/{game_type_cd:ctf|dm|tdm|duel}")
-    config.add_view(rank_index, route_name="rank_index",
-        renderer="rank_index.mako")
+    config.add_view(rank_index, route_name="rank_index", renderer="rank_index.mako")
 
     # SERVER ROUTES
     config.add_route("server_index", "/servers")
-    config.add_view(server_index, route_name="server_index",
-        renderer="server_index.mako")
+    config.add_view(server_index, route_name="server_index", renderer="server_index.mako")
 
-    config.add_route("server_game_index",
-        "/server/{server_id:\d+}/games/page/{page:\d+}")
-    config.add_view(server_game_index, route_name="server_game_index",
-        renderer="server_game_index.mako")
+    config.add_route("server_game_index", "/server/{server_id:\d+}/games/page/{page:\d+}")
+    config.add_view(server_game_index, route_name="server_game_index", renderer="server_game_index.mako")
 
     config.add_route("server_info", "/server/{id:\d+}")
-    config.add_view(server_info, route_name="server_info",
-        renderer="server_info.mako")
+    config.add_view(server_info, route_name="server_info", renderer="server_info.mako")
 
     # MAP ROUTES
+    config.add_route("map_index",      "/maps")
     config.add_route("map_index_json", "/maps.json")
-    config.add_view(map_index_json, route_name="map_index_json",
-        renderer="json")
-
-    config.add_route("map_index", "/maps")
-    config.add_view(map_index, route_name="map_index",
-        renderer="map_index.mako")
+    config.add_view(map_index,      route_name="map_index",      renderer="map_index.mako")
+    config.add_view(map_index_json, route_name="map_index_json", renderer="json")
 
     config.add_route("map_info", "/map/{id:\d+}")
-    config.add_view(map_info, route_name="map_info",
-        renderer="map_info.mako")
+    config.add_view(map_info, route_name="map_info", renderer="map_info.mako")
 
     # SEARCH ROUTES
     config.add_route("search", "search")
-    config.add_view(search, route_name="search",
-        renderer="search.mako")
+    config.add_view(search, route_name="search", renderer="search.mako")
 
     return config.make_wsgi_app()
index d5cd88540db2b4b154626752620268daf6c16776..949f90cd9607fea4a6cd05baf86a4f6dd959ca03 100644 (file)
@@ -34,20 +34,17 @@ class Player(object):
         return pretty_date(self.create_dt)
 
     def __repr__(self):
-        return "<Player(%s, %s)>" % (self.player_id, 
-                self.nick.encode('utf-8'))
+        return "<Player(%s, %s)>" % (self.player_id, self.nick.encode('utf-8'))
 
 
 class GameType(object):
     def __repr__(self):
-        return "<GameType(%s, %s, %s)>" % (self.game_type_cd, self.descr, 
-                self.active_ind)
+        return "<GameType(%s, %s, %s)>" % (self.game_type_cd, self.descr, self.active_ind)
 
 
 class Weapon(object):
     def __repr__(self):
-        return "<Weapon(%s, %s, %s)>" % (self.weapon_cd, self.descr, 
-                self.active_ind)
+        return "<Weapon(%s, %s, %s)>" % (self.weapon_cd, self.descr, self.active_ind)
 
 
 class Server(object):
@@ -82,8 +79,7 @@ class Game(object):
         self.winner = winner
 
     def __repr__(self):
-        return "<Game(%s, %s, %s, %s)>" % (self.game_id, self.start_dt, 
-                self.game_type_cd, self.server_id)
+        return "<Game(%s, %s, %s, %s)>" % (self.game_id, self.start_dt, self.game_type_cd, self.server_id)
 
     def fuzzy_date(self):
         return pretty_date(self.start_dt)
@@ -201,8 +197,7 @@ class PlayerGameStat(object):
         self.create_dt = create_dt
 
     def __repr__(self):
-        return "<PlayerGameStat(%s, %s, %s)>" \
-        % (self.player_id, self.game_id, self.create_dt)
+        return "<PlayerGameStat(%s, %s, %s)>" % (self.player_id, self.game_id, self.create_dt)
 
     def nick_stripped(self):
         if self.nick is None:
@@ -231,8 +226,7 @@ class PlayerGameStat(object):
 
 class Achievement(object):
     def __repr__(self):
-        return "<Achievement(%s, %s, %s)>" % (self.achievement_cd, self.descr,
-                self.limit)
+        return "<Achievement(%s, %s, %s)>" % (self.achievement_cd, self.descr, self.limit)
 
 
 class PlayerAchievement(object):
@@ -242,8 +236,7 @@ class PlayerAchievement(object):
 
 class PlayerWeaponStat(object):
     def __repr__(self):
-        return "<PlayerWeaponStat(%s, %s, %s)>" % (self.player_weapon_stats_id,
-                self.player_id, self.game_id)
+        return "<PlayerWeaponStat(%s, %s, %s)>" % (self.player_weapon_stats_id, self.player_id, self.game_id)
 
 
 class Hashkey(object):
@@ -270,8 +263,7 @@ class PlayerElo(object):
         self.elo = ELOPARMS.initial
 
     def __repr__(self):
-        return "<PlayerElo(pid=%s, gametype=%s, elo=%s)>" % \
-                (self.player_id, self.game_type_cd, self.elo)
+        return "<PlayerElo(pid=%s, gametype=%s, elo=%s)>" % (self.player_id, self.game_type_cd, self.elo)
 
 
 class PlayerRank(object):
@@ -284,8 +276,7 @@ class PlayerRank(object):
 
 
     def __repr__(self):
-        return "<PlayerRank(pid=%s, gametype=%s, rank=%s)>" % \
-                (self.player_id, self.game_type_cd, self.rank)
+        return "<PlayerRank(pid=%s, gametype=%s, rank=%s)>" % (self.player_id, self.game_type_cd, self.rank)
 
 
 def initialize_db(engine=None):
index ee632aed8d90fd3b6bb3cc1a7fbe02792b4e5090..e7f6e389dfa1c32cf43bba4da96e9437b129a815 100644 (file)
@@ -1,8 +1,9 @@
 from xonstat.views.submission import stats_submit
 from xonstat.views.player import player_index, player_info, player_game_index
 from xonstat.views.player import player_accuracy_json
-from xonstat.views.game import game_index, game_info, rank_index
-from xonstat.views.map import map_info, map_index, map_index_json
+from xonstat.views.game   import game_index, game_info, rank_index
+from xonstat.views.map    import map_info, map_index
+from xonstat.views.map    import map_index_json
 from xonstat.views.server import server_info, server_game_index, server_index
 from xonstat.views.search import search_q, search
-from xonstat.views.main import main_index
+from xonstat.views.main   import main_index