Merge branch 'master' of git://git.assembla.com/free_poker_tools.git

This commit is contained in:
eblade 2009-03-30 03:15:21 -04:00
commit fdd8eddcbf
2 changed files with 16 additions and 9 deletions

View File

@ -33,6 +33,9 @@ import xml.dom.minidom
from xml.dom.minidom import Node
def fix_tf(x, default = True):
# The xml parser doesn't translate "True" to True. Therefore, we never get
# True or False from the parser only "True" or "False". So translate the
# string to the python boolean representation.
if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t":
return True
if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
@ -80,11 +83,11 @@ class Site:
self.hudbgcolor = node.getAttribute("bgcolor")
self.hudfgcolor = node.getAttribute("fgcolor")
self.converter = node.getAttribute("converter")
self.enabled = node.getAttribute("enabled")
self.aux_window = node.getAttribute("aux_window")
self.font = node.getAttribute("font")
self.font_size = node.getAttribute("font_size")
self.use_frames = node.getAttribute("use_frames")
self.enabled = fix_tf(node.getAttribute("enabled"), default = True)
self.layout = {}
for layout_node in node.getElementsByTagName('layout'):
@ -583,14 +586,17 @@ class Config:
( 0, 280), (121, 280), ( 46, 30) )
return locations
def get_supported_sites(self):
def get_supported_sites(self, all = False):
"""Returns the list of supported sites."""
return self.supported_sites.keys()
the_sites = []
for site in self.supported_sites.keys():
params = self.get_site_parameters(site)
if all or params['enabled']:
the_sites.append(site)
return the_sites
def get_site_parameters(self, site):
"""Returns a dict of the site parameters for the specified site"""
if not self.supported_sites.has_key(site):
return None
parms = {}
parms["converter"] = self.supported_sites[site].converter
parms["decoder"] = self.supported_sites[site].decoder
@ -602,10 +608,10 @@ class Config:
parms["table_finder"] = self.supported_sites[site].table_finder
parms["HH_path"] = self.supported_sites[site].HH_path
parms["site_name"] = self.supported_sites[site].site_name
parms["enabled"] = self.supported_sites[site].enabled
parms["aux_window"] = self.supported_sites[site].aux_window
parms["font"] = self.supported_sites[site].font
parms["font_size"] = self.supported_sites[site].font_size
parms["enabled"] = self.supported_sites[site].enabled
return parms
def set_site_parameters(self, site_name, converter = None, decoder = None,

View File

@ -202,13 +202,14 @@ class GuiAutoImport (threading.Thread):
filter.show()
def addSites(self, vbox):
for site in self.config.supported_sites.keys():
the_sites = self.config.get_supported_sites()
for site in the_sites:
pathHBox = gtk.HBox(False, 0)
vbox.pack_start(pathHBox, False, True, 0)
pathHBox.show()
paths = self.config.get_default_paths(site)
params = self.config.get_site_parameters(site)
paths = self.config.get_default_paths(site)
self.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]