Exemplo n.º 1
0
 def __init__(self,fullfilepath):
     self._filepath=fullfilepath
     if not os.path.isdir(os.path.dirname(fullfilepath)):
         os.makedirs(os.path.dirname(fullfilepath))
     self._conf=ConfigParser.ConfigParser()
     if os.path.isfile(fullfilepath):
         try:
             self._conf.readfp(open(fullfilepath,"r"))
         except Exception,e:
             PLOG.error("配置文件'%s'打开失败,err=%s"%(self._filepath,e))
Exemplo n.º 2
0
 def __init__(self, fullfilepath):
     self._filepath = fullfilepath
     if not os.path.isdir(os.path.dirname(fullfilepath)):
         os.makedirs(os.path.dirname(fullfilepath))
     self._conf = ConfigParser.ConfigParser()
     if os.path.isfile(fullfilepath):
         try:
             self._conf.readfp(open(fullfilepath, "r"))
         except Exception, e:
             PLOG.error("配置文件'%s'打开失败,err=%s" % (self._filepath, e))
Exemplo n.º 3
0
 def _readvalue(self,fn,section,option,default):
     result=default
     if self._conf.has_section(section):
         if self._conf.has_option(section,option):
             result=fn(section,option)
             PLOG.debug("Option[%s][%s]=%s"%(section,option,str(result)))
         else:
             self._conf.set(section,option,str(default))
             result=default
     else:
         self._conf.add_section(section)
         self._conf.set(section,option,str(default))
         result=default
     return result
Exemplo n.º 4
0
 def _readvalue(self, fn, section, option, default):
     result = default
     if self._conf.has_section(section):
         if self._conf.has_option(section, option):
             result = fn(section, option)
             PLOG.debug("Option[%s][%s]=%s" %
                        (section, option, str(result)))
         else:
             self._conf.set(section, option, str(default))
             result = default
     else:
         self._conf.add_section(section)
         self._conf.set(section, option, str(default))
         result = default
     return result
Exemplo n.º 5
0
 def save(self):
     try:
         self._conf.write(open(self._filepath,"w"))
     except Exception,e:
         PLOG.error("配置文件'%s'保存失败,err=%s"%(self._filepath,e))
Exemplo n.º 6
0
 def save(self):
     try:
         self._conf.write(open(self._filepath, "w"))
     except Exception, e:
         PLOG.error("配置文件'%s'保存失败,err=%s" % (self._filepath, e))