예제 #1
0
파일: config.py 프로젝트: silveregg/txboto
 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)
예제 #2
0
파일: config.py 프로젝트: silveregg/txboto
 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)
예제 #3
0
파일: config.py 프로젝트: silveregg/txboto
 def getfloat(self, section, name, default=0.0):
     try:
         val = ConfigParser.getfloat(self, section, name)
     except:
         val = float(default)
     return val
예제 #4
0
파일: config.py 프로젝트: silveregg/txboto
 def get(self, section, name, default=None):
     try:
         val = ConfigParser.get(self, section, name)
     except:
         val = default
     return val