def save_settings(self, filename = None):
   if not filename and self.__loaded_filepath:
     filepath = self.__loaded_filepath
   else:
     if not filename:
       filename = self.__appname
     filepath = platformdata.getExistingFile(self.__appname, filename + self.config_ext, False)
   with open(filepath, "w") as settingsFile:
     for k in self.__settings:
       settingsFile.write("{} = {}\n".format(k, self.__settings[k]))
 def load_settings(self, filename = None):
   data = None
   if not filename:  
     filename = self.__appname
   filepath = platformdata.getExistingFile(self.__appname, filename + self.config_ext, True)
   if not filepath:
     raise IOError("Cannot find settings file %s.conf" % filename)
   with open(filepath,"r") as settingsFile:
       data = settingsFile.readlines()
   if data != None:
     self.__loaded_filepath = filepath
     for line in data:
       line = line.strip()
       if len(line) == 0:
         continue
       # Lines beginning with # are comments
       if line[0]=='#':
         continue
       ix = line.find('=')
       if ix < 0:
         continue
       self.__settings[line[0:ix].strip().upper()]=line[ix+1:].strip()