mostly None checkings fixed (== to is != to is not)

This commit is contained in:
unknown
2009-11-03 14:30:52 -05:00
parent 7667a39ded
commit a6b7292943
20 changed files with 101 additions and 103 deletions
+31 -33
View File
@@ -316,22 +316,20 @@ class Config:
# we check the existence of "file" and try to recover if it doesn't exist
self.default_config_path = self.get_default_config_path()
if file != None: # configuration file path has been passed
if file is not None: # config file path passed in
file = os.path.expanduser(file)
if not os.path.exists(file):
print "Configuration file %s not found. Using defaults." % (file)
sys.stderr.write("Configuration file %s not found. Using defaults." % (file))
file = None
if file == None: # configuration file path not passed or invalid
if file is None: # configuration file path not passed or invalid
file = self.find_config() #Look for a config file in the normal places
if file == None: # no config file in the normal places
if file is None: # no config file in the normal places
file = self.find_example_config() #Look for an example file to edit
if file != None:
pass
if file == None: # that didn't work either, just die
if file is None: # that didn't work either, just die
print "No HUD_config_xml found after looking in current directory and "+self.default_config_path+"\nExiting"
sys.stderr.write("No HUD_config_xml found after looking in current directory and "+self.default_config_path+"\nExiting")
print "press enter to continue"
@@ -520,7 +518,7 @@ class Config:
def get_layout_node(self, site_node, layout):
for layout_node in site_node.getElementsByTagName("layout"):
if layout_node.getAttribute("max") == None:
if layout_node.getAttribute("max") is None:
return None
if int( layout_node.getAttribute("max") ) == int( layout ):
return layout_node
@@ -536,7 +534,7 @@ class Config:
return location_node
def save(self, file = None):
if file != None:
if file is not None:
with open(file, 'w') as f:
self.doc.writexml(f)
else:
@@ -549,7 +547,7 @@ class Config:
site_node = self.get_site_node(site_name)
layout_node = self.get_layout_node(site_node, max)
# TODO: how do we support inserting new layouts?
if layout_node == None:
if layout_node is None:
return
for i in range(1, max + 1):
location_node = self.get_location_node(layout_node, i)
@@ -560,7 +558,7 @@ class Config:
def edit_aux_layout(self, aux_name, max, width = None, height = None, locations = None):
aux_node = self.get_aux_node(aux_name)
layout_node = self.get_layout_node(aux_node, max)
if layout_node == None:
if layout_node is None:
print "aux node not found"
return
print "editing locations =", locations
@@ -608,17 +606,17 @@ class Config:
db_pass = None, db_server = None, db_type = None):
db_node = self.get_db_node(db_name)
if db_node != None:
if db_ip != None: db_node.setAttribute("db_ip", db_ip)
if db_user != None: db_node.setAttribute("db_user", db_user)
if db_pass != None: db_node.setAttribute("db_pass", db_pass)
if db_server != None: db_node.setAttribute("db_server", db_server)
if db_type != None: db_node.setAttribute("db_type", db_type)
if db_ip is not None: db_node.setAttribute("db_ip", db_ip)
if db_user is not None: db_node.setAttribute("db_user", db_user)
if db_pass is not None: db_node.setAttribute("db_pass", db_pass)
if db_server is not None: db_node.setAttribute("db_server", db_server)
if db_type is not None: db_node.setAttribute("db_type", db_type)
if self.supported_databases.has_key(db_name):
if db_ip != None: self.supported_databases[db_name].dp_ip = db_ip
if db_user != None: self.supported_databases[db_name].dp_user = db_user
if db_pass != None: self.supported_databases[db_name].dp_pass = db_pass
if db_server != None: self.supported_databases[db_name].dp_server = db_server
if db_type != None: self.supported_databases[db_name].dp_type = db_type
if db_ip is not None: self.supported_databases[db_name].dp_ip = db_ip
if db_user is not None: self.supported_databases[db_name].dp_user = db_user
if db_pass is not None: self.supported_databases[db_name].dp_pass = db_pass
if db_server is not None: self.supported_databases[db_name].dp_server = db_server
if db_type is not None: self.supported_databases[db_name].dp_type = db_type
return
def getDefaultSite(self):
@@ -809,19 +807,19 @@ class Config:
font = None, font_size = None):
"""Sets the specified site parameters for the specified site."""
site_node = self.get_site_node(site_name)
if db_node != None:
if converter != None: site_node.setAttribute("converter", converter)
if decoder != None: site_node.setAttribute("decoder", decoder)
if hudbgcolor != None: site_node.setAttribute("hudbgcolor", hudbgcolor)
if hudfgcolor != None: site_node.setAttribute("hudfgcolor", hudfgcolor)
if hudopacity != None: site_node.setAttribute("hudopacity", hudopacity)
if screen_name != None: site_node.setAttribute("screen_name", screen_name)
if site_path != None: site_node.setAttribute("site_path", site_path)
if table_finder != None: site_node.setAttribute("table_finder", table_finder)
if HH_path != None: site_node.setAttribute("HH_path", HH_path)
if enabled != None: site_node.setAttribute("enabled", enabled)
if font != None: site_node.setAttribute("font", font)
if font_size != None: site_node.setAttribute("font_size", font_size)
if db_node is not None:
if converter is not None: site_node.setAttribute("converter", converter)
if decoder is not None: site_node.setAttribute("decoder", decoder)
if hudbgcolor is not None: site_node.setAttribute("hudbgcolor", hudbgcolor)
if hudfgcolor is not None: site_node.setAttribute("hudfgcolor", hudfgcolor)
if hudopacity is not None: site_node.setAttribute("hudopacity", hudopacity)
if screen_name is not None: site_node.setAttribute("screen_name", screen_name)
if site_path is not None: site_node.setAttribute("site_path", site_path)
if table_finder is not None: site_node.setAttribute("table_finder", table_finder)
if HH_path is not None: site_node.setAttribute("HH_path", HH_path)
if enabled is not None: site_node.setAttribute("enabled", enabled)
if font is not None: site_node.setAttribute("font", font)
if font_size is not None: site_node.setAttribute("font_size", font_size)
return
def get_aux_windows(self):