def _readPose(self, filename): ''' Read the pose file and build up the internal poseDict TODO: do we allow the data to be filled from the pose filter thats stored??????? ''' if filename: if os.path.exists(filename): #for key, val in configobj.ConfigObj(filename)['filterNode_settings'].items(): # self.settings.__dict__[key]=decodeString(val) self.poseDict = configobj.ConfigObj(filename)['poseData'] if 'info' in configobj.ConfigObj(filename): self.infoDict = configobj.ConfigObj(filename)['info'] if 'skeletonDict' in configobj.ConfigObj(filename): self.skeletonDict = configobj.ConfigObj( filename)['skeletonDict'] else: raise StandardError('Given filepath doesnt not exist : %s' % filename) else: raise StandardError('No FilePath given to read the pose from')
def _writePose(self, filepath): ''' Write the Pose ConfigObj to file ''' ConfigObj = configobj.ConfigObj(indent_type='\t') ConfigObj['filterNode_settings'] = self.settings.__dict__ ConfigObj['poseData'] = self.poseDict ConfigObj['info'] = self.infoDict if self.skeletonDict: ConfigObj['skeletonDict'] = self.skeletonDict ConfigObj.filename = filepath ConfigObj.write()
def write(self, filepath = None): ''' Write the Data ConfigObj to file ''' filepath = self.validateFilepath(filepath) self.updateSourceSkinData() ConfigObj = configobj.ConfigObj(indent_type='\t') ConfigObj['configType']= 'cgmSkinConfig' ConfigObj['source']=self.d_source ConfigObj['general']=self.d_general ConfigObj['skin']=self.d_sourceSkin ConfigObj['influences']=self.d_sourceInfluences ConfigObj['weights']=self.d_weights ConfigObj.filename = filepath ConfigObj.write() return True
def read(self, filepath = None, report = False): ''' Read the Data ConfigObj from file and report the data if so desired. ''' filepath = self.validateFilepath(filepath, fileMode = 1) if not os.path.exists(filepath): raise ValueError('Given filepath doesnt not exist : %s' % filepath) _config = configobj.ConfigObj(filepath) if _config.get('configType') != 'cgmSkinConfig': raise ValueError,"This isn't a cgmSkinConfig config | {0}".format(filepath) for k in data._configToStored.keys(): if _config.has_key(k): self.__dict__[data._configToStored[k]] = _config[k] else: log.error("Config file missing section {0}".format(k)) return False if report:self.report() return True