Ejemplo n.º 1
0
 def save_option(self, path, section, option, value):
     """
     Write the specified Section.Option to the config file specified by path.
     Replace any previous value.  If the path doesn't exist, create it.
     Also add the option the the in-memory config.
     """
     config = ConfigParser()
     config.read(path)
     if not config.has_section(section):
         config.add_section(section)
     config.set(section, option, value)
     fp = open(path, "w")
     config.write(fp)
     fp.close()
     if not self.has_section(section):
         self.add_section(section)
     self.set(section, option, value)
Ejemplo n.º 2
0
 def __init__(self, path=None, fp=None, do_load=True):
     # We don't use ``super`` here, because ``ConfigParser`` still uses
     # old-style classes.
     ConfigParser.__init__(self, {"working_dir": "/mnt/pyami", "debug": "0"})
     if do_load:
         if path:
             self.load_from_path(path)
         elif fp:
             self.readfp(fp)
         else:
             self.read(TxBotoConfigLocations)
         if "AWS_CREDENTIAL_FILE" in os.environ:
             full_path = expanduser(os.environ["AWS_CREDENTIAL_FILE"])
             try:
                 self.load_credential_file(full_path)
             except IOError:
                 warnings.warn("Unable to load AWS_CREDENTIAL_FILE (%s)" % full_path)
Ejemplo n.º 3
0
 def getfloat(self, section, name, default=0.0):
     try:
         val = ConfigParser.getfloat(self, section, name)
     except:
         val = float(default)
     return val
Ejemplo n.º 4
0
 def get(self, section, name, default=None):
     try:
         val = ConfigParser.get(self, section, name)
     except:
         val = default
     return val