From 04e8f117d5ebd47a29307328002d5f1bc49449ef Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Wed, 24 Feb 2010 17:06:36 -0500 Subject: [PATCH] Revert "Trivial refactor of get_stats_from_hand for readability." This reverts commit 03880bbc63f7635821b5ff5ac75796d83ef6a94a. --- pyfpdb/Database.py | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 76addf59..0303aad2 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -643,29 +643,6 @@ class Database: , hero_id = -1 , num_seats = 6 ): - - (hud_style, h_hud_style, query, subs) = self.prep_aggregation(hand, hud_params, hero_id, num_seats) - - c = self.connection.cursor() - -# now get the stats - stat_dict = {} - c.execute(self.sql.query[query], subs) - colnames = [desc[0] for desc in c.description] - for row in c.fetchall(): - playerid = row[0] - if (playerid == hero_id and h_hud_style != 'S') or (playerid != hero_id and hud_style != 'S'): - t_dict = {} - for name, val in zip(colnames, row): - t_dict[name.lower()] = val -# print t_dict - stat_dict[t_dict['player_id']] = t_dict - - return stat_dict - - def prep_aggregation(self, hand, hud_params, hero_id, num_seats): -# This sorts through the all the info having to do with aggregation -# and returns what get_stats needs. hud_style = hud_params['hud_style'] agg_bb_mult = hud_params['agg_bb_mult'] seats_style = hud_params['seats_style'] @@ -675,6 +652,8 @@ class Database: h_seats_style = hud_params['h_seats_style'] h_seats_cust_nums = hud_params['h_seats_cust_nums'] + stat_dict = {} + if seats_style == 'A': seats_min, seats_max = 0, 10 elif seats_style == 'C': @@ -736,7 +715,23 @@ class Database: subs = (hand ,hero_id, stylekey, agg_bb_mult, agg_bb_mult, seats_min, seats_max # hero params ,hero_id, h_stylekey, h_agg_bb_mult, h_agg_bb_mult, h_seats_min, h_seats_max) # villain params - return (hud_style, h_hud_style, query, subs) + + #print "get stats: hud style =", hud_style, "query =", query, "subs =", subs + c = self.connection.cursor() + +# now get the stats + c.execute(self.sql.query[query], subs) + colnames = [desc[0] for desc in c.description] + for row in c.fetchall(): + playerid = row[0] + if (playerid == hero_id and h_hud_style != 'S') or (playerid != hero_id and hud_style != 'S'): + t_dict = {} + for name, val in zip(colnames, row): + t_dict[name.lower()] = val +# print t_dict + stat_dict[t_dict['player_id']] = t_dict + + return stat_dict # uses query on handsplayers instead of hudcache to get stats on just this session def get_stats_from_hand_session(self, hand, stat_dict, hero_id