コード例 #1
0
 def get_option(self, section, option, default=None):
     """ Wrapper around ConfigParser.get. 
     Automatically adds any missing sections, adds the ability
     to write a default value, and if one is provided prints if
     the default or a previously saved value is returned.
     """
     if not self.has_section(section):
         self.add_section(section)
     if self.has_option(section, option):
         ret = ConfigParser.get(self, section, option)
         logging.debug("found %s in configuration: %s", option, ret)
     else:
         logging.debug("did not find %s in configuration, using default %s", option, default)
         self.set(section, option, str(default), save=True)
         ret = default
     return misc.smart_type(ret)
コード例 #2
0
 def get_option(self, section, option, default=None):
     """ Wrapper around ConfigParser.get. 
     Automatically adds any missing sections, adds the ability
     to write a default value, and if one is provided prints if
     the default or a previously saved value is returned.
     """
     if not self.has_section(section):
         self.add_section(section)
     if self.has_option(section, option):
         ret = ConfigParser.get(self, section, option)
         if default:
             log( ''.join(['found ', option, ' in configuration ', ret]))
     else:
         log( ''.join(['did not find ', option,
                        ' in configuration, setting default ', str(default)]))
         self.set(section, option, str(default), save=True)
         ret = default
     return misc.smart_type(ret)
コード例 #3
0
 def __setitem__(self, key, value):
     self.__values[key] = misc.smart_type(value)