コード例 #1
0
ファイル: ReadCFG.py プロジェクト: dodsonicrar/DDFacet
 def read (self, filename):
     self.filename = filename
     if six.PY3:
         self.Config = config = ConfigParser(dict_type=OrderedDict)
     else:
         self.Config = config = ConfigParser.ConfigParser(dict_type=OrderedDict)
     config.optionxform = str
     success = config.read(self.filename)
     self.success = bool(len(success))
     if self.success:
         self.sections = config.sections()
         for section in self.sections:
             self.value_dict[section], self.attr_dict[section] = self.read_section(config, section)
     # now migrate from previous versions
     self.version = self.value_dict.get('Misc', {}).get('ParsetVersion', 0.0)
     if self.version != 0.2:
         if self.version != 0.1:
           self._migrate_ancient_0_1()
         self._migrate_0_1_0_2()
         self.migrated = self.version
         self.version = self.value_dict['Misc']['ParsetVersion'] = 0.2
     else:
         self.migrated = None