get_sites now returns only enabled sites--enabled is the default in Config.
This commit is contained in:
		
							parent
							
								
									93d2b50867
								
							
						
					
					
						commit
						fb4e818ed2
					
				| 
						 | 
					@ -33,6 +33,9 @@ import xml.dom.minidom
 | 
				
			||||||
from xml.dom.minidom import Node
 | 
					from xml.dom.minidom import Node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def fix_tf(x, default = True):
 | 
					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":
 | 
					    if x == "1" or x == 1 or string.lower(x) == "true"  or string.lower(x) == "t":
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
    if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
 | 
					    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.hudbgcolor   = node.getAttribute("bgcolor")
 | 
				
			||||||
        self.hudfgcolor   = node.getAttribute("fgcolor")
 | 
					        self.hudfgcolor   = node.getAttribute("fgcolor")
 | 
				
			||||||
        self.converter    = node.getAttribute("converter")
 | 
					        self.converter    = node.getAttribute("converter")
 | 
				
			||||||
        self.enabled      = node.getAttribute("enabled")
 | 
					 | 
				
			||||||
        self.aux_window   = node.getAttribute("aux_window")
 | 
					        self.aux_window   = node.getAttribute("aux_window")
 | 
				
			||||||
        self.font         = node.getAttribute("font")
 | 
					        self.font         = node.getAttribute("font")
 | 
				
			||||||
        self.font_size    = node.getAttribute("font_size")
 | 
					        self.font_size    = node.getAttribute("font_size")
 | 
				
			||||||
        self.use_frames    = node.getAttribute("use_frames")
 | 
					        self.use_frames    = node.getAttribute("use_frames")
 | 
				
			||||||
 | 
					        self.enabled      = fix_tf(node.getAttribute("enabled"), default = True)
 | 
				
			||||||
        self.layout       = {}
 | 
					        self.layout       = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for layout_node in node.getElementsByTagName('layout'):
 | 
					        for layout_node in node.getElementsByTagName('layout'):
 | 
				
			||||||
| 
						 | 
					@ -583,14 +586,17 @@ class Config:
 | 
				
			||||||
                          (  0, 280), (121, 280), ( 46,  30) )
 | 
					                          (  0, 280), (121, 280), ( 46,  30) )
 | 
				
			||||||
        return locations
 | 
					        return locations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_supported_sites(self):
 | 
					    def get_supported_sites(self, all = False):
 | 
				
			||||||
        """Returns the list of supported sites."""
 | 
					        """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):
 | 
					    def get_site_parameters(self, site):
 | 
				
			||||||
        """Returns a dict of the site parameters for the specified site"""
 | 
					        """Returns a dict of the site parameters for the specified site"""
 | 
				
			||||||
        if not self.supported_sites.has_key(site):
 | 
					 | 
				
			||||||
            return None
 | 
					 | 
				
			||||||
        parms = {}
 | 
					        parms = {}
 | 
				
			||||||
        parms["converter"]    = self.supported_sites[site].converter
 | 
					        parms["converter"]    = self.supported_sites[site].converter
 | 
				
			||||||
        parms["decoder"]      = self.supported_sites[site].decoder
 | 
					        parms["decoder"]      = self.supported_sites[site].decoder
 | 
				
			||||||
| 
						 | 
					@ -602,10 +608,10 @@ class Config:
 | 
				
			||||||
        parms["table_finder"] = self.supported_sites[site].table_finder
 | 
					        parms["table_finder"] = self.supported_sites[site].table_finder
 | 
				
			||||||
        parms["HH_path"]      = self.supported_sites[site].HH_path
 | 
					        parms["HH_path"]      = self.supported_sites[site].HH_path
 | 
				
			||||||
        parms["site_name"]    = self.supported_sites[site].site_name
 | 
					        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["aux_window"]   = self.supported_sites[site].aux_window
 | 
				
			||||||
        parms["font"]         = self.supported_sites[site].font
 | 
					        parms["font"]         = self.supported_sites[site].font
 | 
				
			||||||
        parms["font_size"]    = self.supported_sites[site].font_size
 | 
					        parms["font_size"]    = self.supported_sites[site].font_size
 | 
				
			||||||
 | 
					        parms["enabled"]      = self.supported_sites[site].enabled
 | 
				
			||||||
        return parms
 | 
					        return parms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_site_parameters(self, site_name, converter = None, decoder = None,
 | 
					    def set_site_parameters(self, site_name, converter = None, decoder = None,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -202,13 +202,14 @@ class GuiAutoImport (threading.Thread):
 | 
				
			||||||
        filter.show()
 | 
					        filter.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def addSites(self, vbox):
 | 
					    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)
 | 
					            pathHBox = gtk.HBox(False, 0)
 | 
				
			||||||
            vbox.pack_start(pathHBox, False, True, 0)
 | 
					            vbox.pack_start(pathHBox, False, True, 0)
 | 
				
			||||||
            pathHBox.show()
 | 
					            pathHBox.show()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
            paths = self.config.get_default_paths(site)
 | 
					 | 
				
			||||||
            params = self.config.get_site_parameters(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.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
 | 
				
			||||||
            self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
 | 
					            self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user