Merge branch 'sqlcoder'

This commit is contained in:
steffen123 2010-08-02 14:34:35 +02:00
commit b10868347f
3 changed files with 105 additions and 33 deletions

View File

@ -505,6 +505,41 @@ class General(dict):
s = s + " %s = %s\n" % (k, self[k]) s = s + " %s = %s\n" % (k, self[k])
return(s) 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: class Config:
def __init__(self, file = None, dbname = ''): def __init__(self, file = None, dbname = ''):
# "file" is a path to an xml file with the fpdb/HUD configuration # "file" is a path to an xml file with the fpdb/HUD configuration
@ -560,10 +595,14 @@ class Config:
self.db_selected = None # database the user would like to use self.db_selected = None # database the user would like to use
self.tv = None self.tv = None
self.general = General() self.general = General()
self.gui_cash_stats = GUICashStats()
for gen_node in doc.getElementsByTagName("general"): for gen_node in doc.getElementsByTagName("general"):
self.general.add_elements(node=gen_node) # add/overwrite elements in self.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") # s_sites = doc.getElementsByTagName("supported_sites")
for site_node in doc.getElementsByTagName("site"): for site_node in doc.getElementsByTagName("site"):
site = Site(node = site_node) site = Site(node = site_node)
@ -1151,6 +1190,9 @@ class Config:
def get_general_params(self): def get_general_params(self):
return( self.general ) return( self.general )
def get_gui_cash_stat_params(self):
return( self.gui_cash_stats )
if __name__== "__main__": if __name__== "__main__":
c = Config() c = Config()
@ -1224,6 +1266,8 @@ if __name__== "__main__":
print "start up path = ", c.execution_path("") print "start up path = ", c.execution_path("")
print "gui_cash_stats =", c.gui_cash_stats
try: try:
from xml.dom.ext import PrettyPrint from xml.dom.ext import PrettyPrint
for site_node in c.doc.getElementsByTagName("site"): for site_node in c.doc.getElementsByTagName("site"):

View File

@ -26,6 +26,20 @@ import gobject
import Configuration import Configuration
rewrite = { 'general' : 'General', 'supported_databases' : 'Databases'
, 'import' : 'Import', 'hud_ui' : 'HUD'
, 'supported_sites' : 'Sites', 'supported_games' : 'Games'
, 'popup_windows' : 'Popup Windows', 'pu' : 'Window'
, 'pu_name' : 'Popup Name', 'pu_stat' : 'Stat'
, 'pu_stat_name' : 'Stat Name'
, 'aux_windows' : 'Auxiliary Windows', 'aw stud_mucked' : 'stud_mucked'
, 'aw mucked' : 'mucked', 'hhcs' : 'Hand History Converters'
, 'gui_cash_stats' : 'Ring Player Stats', 'field_type' : 'Field Type'
, 'col_title' : 'Column Heading', 'xalignment' : 'Left/Right Align'
, 'disp_all' : 'Show in Summaries', 'disp_posn' : 'Show in Position Stats'
, 'col_name' : 'Stat Name', 'field_format' : 'Format'
}
class GuiPrefs: class GuiPrefs:
def __init__(self, config, mainwin, dia, parentwin): def __init__(self, config, mainwin, dia, parentwin):
@ -78,6 +92,13 @@ class GuiPrefs:
self.tree_box.show() self.tree_box.show()
self.dialog.show() self.dialog.show()
def rewriteText(self, s):
upd = False
if s in rewrite:
s = rewrite[s]
upd = True
return( (s,upd) )
def addTreeRows(self, parent, node): def addTreeRows(self, parent, node):
if (node.nodeType == node.ELEMENT_NODE): if (node.nodeType == node.ELEMENT_NODE):
(setting, value) = (node.nodeName, None) (setting, value) = (node.nodeName, None)
@ -94,11 +115,15 @@ class GuiPrefs:
iter = self.configStore.append( parent, [node, setting, value] ) iter = self.configStore.append( parent, [node, setting, value] )
if node.hasAttributes(): if node.hasAttributes():
for i in xrange(node.attributes.length): for i in xrange(node.attributes.length):
self.configStore.append( iter, [node, node.attributes.item(i).localName, node.attributes.item(i).value] ) localName,updated = self.rewriteText( node.attributes.item(i).localName )
if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site'): self.configStore.append( iter, [node, localName, node.attributes.item(i).value] )
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 name = " " + node.attributes.item(i).value
if name != "":
self.configStore.set_value(iter, 1, setting+name) label,updated = self.rewriteText(setting+name)
if name != "" or updated:
self.configStore.set_value(iter, 1, label)
if node.hasChildNodes(): if node.hasChildNodes():
for elem in node.childNodes: for elem in node.childNodes:
self.addTreeRows(iter, elem) self.addTreeRows(iter, elem)

View File

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