store column info for cash stats in config. Can now enhance gui to let user change column choices

This commit is contained in:
sqlcoder 2010-07-31 20:55:29 +01:00
parent 1688dfc991
commit 66cbf49cdc
3 changed files with 77 additions and 30 deletions

View File

@ -500,6 +500,41 @@ class General(dict):
s = s + " %s = %s\n" % (k, self[k])
return(s)
class GUICashStats(list):
"""<gui_cash_stats>
<col col_name="game" col_title="Game" disp_all="True" disp_posn="True" field_format="%s" field_type="str" xalignment="0.0" />
...
</gui_cash_stats>
"""
def __init__(self):
super(GUICashStats, self).__init__()
def add_elements(self, node):
# is this needed?
for child in node.childNodes:
if child.nodeType == child.ELEMENT_NODE:
col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment=None, None, True, True, "%s", "str", 0.0
if child.hasAttribute('col_name'): col_name = child.getAttribute('col_name')
if child.hasAttribute('col_title'): col_title = child.getAttribute('col_title')
if child.hasAttribute('disp_all'): disp_all = string_to_bool(child.getAttribute('disp_all'))
if child.hasAttribute('disp_posn'): disp_posn = string_to_bool(child.getAttribute('disp_posn'))
if child.hasAttribute('field_format'): field_format = child.getAttribute('field_format')
if child.hasAttribute('field_type'): field_type = child.getAttribute('field_type')
try:
if child.hasAttribute('xalignment'): xalignment = float(child.getAttribute('xalignment'))
except ValueError:
print "bad number in xalignment was ignored"
log.info("bad number in xalignment was ignored")
self.append( [col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment] )
# def __str__(self):
# s = ""
# for l in self:
# s = s + " %s = %s\n" % (k, self[k])
# return(s)
class Config:
def __init__(self, file = None, dbname = ''):
# "file" is a path to an xml file with the fpdb/HUD configuration
@ -555,10 +590,14 @@ class Config:
self.db_selected = None # database the user would like to use
self.tv = None
self.general = General()
self.gui_cash_stats = GUICashStats()
for gen_node in doc.getElementsByTagName("general"):
self.general.add_elements(node=gen_node) # add/overwrite elements in self.general
for gcs_node in doc.getElementsByTagName("gui_cash_stats"):
self.gui_cash_stats.add_elements(node=gcs_node) # add/overwrite elements in self.gui_cash_stats
# s_sites = doc.getElementsByTagName("supported_sites")
for site_node in doc.getElementsByTagName("site"):
site = Site(node = site_node)
@ -1146,6 +1185,9 @@ class Config:
def get_general_params(self):
return( self.general )
def get_gui_cash_stat_params(self):
return( self.gui_cash_stats )
if __name__== "__main__":
c = Config()
@ -1219,6 +1261,8 @@ if __name__== "__main__":
print "start up path = ", c.execution_path("")
print "gui_cash_stats =", c.gui_cash_stats
try:
from xml.dom.ext import PrettyPrint
for site_node in c.doc.getElementsByTagName("site"):

View File

@ -95,7 +95,7 @@ class GuiPrefs:
if node.hasAttributes():
for i in xrange(node.attributes.length):
self.configStore.append( iter, [node, node.attributes.item(i).localName, node.attributes.item(i).value] )
if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site'):
if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site', 'col_name'):
name = " " + node.attributes.item(i).value
if name != "":
self.configStore.set_value(iter, 1, setting+name)

View File

@ -31,7 +31,9 @@ import Filters
import Charset
import GuiPlayerStats
colalias,colshowsumm,colshowposn,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5,6
#colalias,colshowsumm,colshowposn,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5,6
#new order in config file:
colalias,colheading,colshowsumm,colshowposn,colformat,coltype,colxalign = 0,1,2,3,4,5,6
ranks = {'x':0, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}
class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
@ -89,34 +91,35 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
# ToDo: create popup to adjust column config
# columns to display, keys match column name returned by sql, values in tuple are:
# is column displayed(summary then position), column heading, xalignment, formatting, celltype
self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"]
, ["hand", False, False, "Hand", 0.0, "%s", "str"] # true not allowed for this line
, ["plposition", False, False, "Posn", 1.0, "%s", "str"] # true not allowed for this line (set in code)
, ["pname", False, False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
, ["n", True, True, "Hds", 1.0, "%1.0f", "str"]
, ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"]
, ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"]
, ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"]
, ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"]
, ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"]
, ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"]
, ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"]
, ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"]
, ["steals", True, True, "Steals", 1.0, "%3.1f", "str"]
, ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"]
, ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"]
, ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"]
, ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"]
, ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"]
, ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"]
, ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"]
, ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"]
, ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"]
, ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"]
, ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"]
, ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"]
, ["variance", True, True, "Variance", 1.0, "%5.2f", "str"]
]
self.columns = self.conf.get_gui_cash_stat_params()
# self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"]
# , ["hand", False, False, "Hand", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["plposition", False, False, "Posn", 1.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["pname", False, False, "Name", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["n", True, True, "Hds", 1.0, "%1.0f", "str"]
# , ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"]
# , ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"]
# , ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"]
# , ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"]
# , ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"]
# , ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"]
# , ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"]
# , ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"]
# , ["steals", True, True, "Steals", 1.0, "%3.1f", "str"]
# , ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"]
# , ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"]
# , ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"]
# , ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"]
# , ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"]
# , ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"]
# , ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"]
# , ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"]
# , ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"]
# , ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"]
# , ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"]
# , ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"]
# , ["variance", True, True, "Variance", 1.0, "%5.2f", "str"]
# ]
# Detail filters: This holds the data used in the popup window, extra values are
# added at the end of these lists during processing