当前位置: 首页>>代码示例>>Python>>正文


Python Red9_CoreUtils类代码示例

本文整理汇总了Python中Red9_CoreUtils的典型用法代码示例。如果您正苦于以下问题:Python Red9_CoreUtils类的具体用法?Python Red9_CoreUtils怎么用?Python Red9_CoreUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Red9_CoreUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _matchNodesToPoseData

 def _matchNodesToPoseData(self, nodes):
     '''
     Main filter to extract matching data pairs prior to processing
     return : tuple such that :  (poseDict[key], destinationNode)
     NOTE: I've changed this so that matchMethod is now an internal PoseData attr
     @param nodes: nodes to try and match from the poseDict
     '''
     matchedPairs=[]
     log.info('using matchMethod : %s' % self.matchMethod)
     if self.matchMethod=='stripPrefix' or self.matchMethod=='base':
         log.info('matchMethodStandard : %s' % self.matchMethod)
         matchedPairs=r9Core.matchNodeLists([key for key in self.poseDict.keys()], nodes, matchMethod=self.matchMethod)
     if self.matchMethod=='index':
         for i, node in enumerate(nodes):
             for key in self.poseDict.keys():
                 if int(self.poseDict[key]['ID'])==i:
                     matchedPairs.append((key,node))
                     log.info('poseKey : %s %s >> matchedSource : %s %i' % (key, self.poseDict[key]['ID'], node, i))
                     break
     if self.matchMethod=='metaData':
         getMetaDict=self.metaRig.getNodeConnectionMetaDataMap  # optimisation
         poseKeys=dict(self.poseDict)  # optimisation
         for node in nodes:
             try:
                 metaDict=getMetaDict(node)
                 for key in poseKeys:
                     if poseKeys[key]['metaData']==metaDict:
                         matchedPairs.append((key,node))
                         poseKeys.pop(key)
                         break
             except:
                 log.info('FAILURE to load MetaData pose blocks - Reverting to Name')
                 matchedPairs=r9Core.matchNodeLists([key for key in self.poseDict.keys()], nodes)
     return matchedPairs
开发者ID:nicolasboselli,项目名称:test,代码行数:34,代码来源:Red9_PoseSaver.py

示例2: matchInternalPoseObjects

 def matchInternalPoseObjects(self, nodes=None, fromFilter=True):
     '''
     This is a throw-away and only used in the UI to select for debugging!
     from a given poseFile return or select the internal stored objects
     '''
     InternalNodes=[]
     if not fromFilter:
         #no filter, we just pass in the longName thats stored
         for key in self.poseDict.keys():
             if cmds.objExists(self.poseDict[key]['longName']):
                 InternalNodes.append(self.poseDict[key]['longName'])
             elif cmds.objExists(key):
                 InternalNodes.append(key)
             elif cmds.objExists(r9Core.nodeNameStrip(key)):
                 InternalNodes.append(r9Core.nodeNameStrip(key))
     else:
         #use the internal Poses filter and then Match against scene nodes
         if self.settings.filterIsActive():
             filterData=r9Core.FilterNode(nodes,self.settings).ProcessFilter()
             matchedPairs=self._matchNodesToPoseData(filterData)
             if matchedPairs:
                 InternalNodes=[node for _,node in matchedPairs]
     if not InternalNodes:
         raise StandardError('No Matching Nodes found!!')
     return InternalNodes
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:25,代码来源:Red9_PoseSaver.py

示例3: _snapNodestoPosePnts

 def _snapNodestoPosePnts(self):
     '''
     snap each MAYA node to it's respective pntCloud point
     '''
     for pnt, node in self.posePointCloudNodes:
         log.debug('snapping Ctrl : %s > %s : %s' % (r9Core.nodeNameStrip(node), pnt, node))
         r9Anim.AnimFunctions.snap([pnt,node])
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:7,代码来源:Red9_PoseSaver.py

示例4: buildOffsetCloud

 def buildOffsetCloud(self, rootReference=None, raw=False):
     '''
     Build a point cloud up for each node in nodes
     :param nodes: list of objects to be in the cloud
     :param rootReference: the node used for the initial pivot location
     :param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
     '''
     self.posePointRoot=cmds.ls(cmds.spaceLocator(name='posePointCloud'),l=True)[0]
     
     ppcShape=cmds.listRelatives(self.posePointRoot,type='shape')[0]
     cmds.setAttr("%s.localScaleZ" % ppcShape, 30)
     cmds.setAttr("%s.localScaleX" % ppcShape, 30)
     cmds.setAttr("%s.localScaleY" % ppcShape, 30)
     
     if self.settings:
         if self.prioritySnapOnly:
             self.settings.searchPattern=self.settings.filterPriority
         self.inputNodes=r9Core.FilterNode(self.inputNodes, self.settings).ProcessFilter()
     if self.inputNodes:
         self.inputNodes.reverse()  # for the snapping operations
     
     if self.mayaUpAxis=='y':
         cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
     if rootReference:  # and not mesh:
         r9Anim.AnimFunctions.snap([rootReference,self.posePointRoot])
     for node in self.inputNodes:
         pnt=cmds.spaceLocator(name='pp_%s' % r9Core.nodeNameStrip(node))[0]
         if not raw:
             r9Anim.AnimFunctions.snap([node,pnt])
         cmds.parent(pnt,self.posePointRoot)
         self.posePointCloudNodes.append((pnt,node))
     cmds.select(self.posePointRoot)
     if self.mesh:
         self.shapeSwapMesh()
     return self.posePointCloudNodes
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:35,代码来源:Red9_PoseSaver.py

示例5: _buildPoseDict

    def _buildPoseDict(self, nodes):
        """
        Build the internal poseDict up from the given nodes. This is the
        core of the Pose System
        """
        if self.metaPose:
            getMetaDict = self.metaRig.getNodeConnectionMetaDataMap  # optimisation

        for i, node in enumerate(nodes):
            key = r9Core.nodeNameStrip(node)
            self.poseDict[key] = {}
            self.poseDict[key]["ID"] = i  # selection order index
            self.poseDict[key]["longName"] = node  # longNode name

            if self.metaPose:
                self.poseDict[key]["metaData"] = getMetaDict(node)  # metaSystem the node is wired too

            channels = r9Anim.getSettableChannels(node, incStatics=True)
            if channels:
                self.poseDict[key]["attrs"] = {}
                for attr in channels:
                    if attr in self.skipAttrs:
                        log.debug("Skipping attr as requested : %s" % attr)
                        continue
                    try:
                        if (
                            cmds.getAttr("%s.%s" % (node, attr), type=True) == "TdataCompound"
                        ):  # blendShape weights support
                            attrs = cmds.aliasAttr(node, q=True)[::2]  # extract the target channels from the multi
                            for attr in attrs:
                                self.poseDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (node, attr))
                        else:
                            self.poseDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (node, attr))
                    except:
                        log.debug("%s : attr is invalid in this instance" % attr)
开发者ID:vitattoo,项目名称:Red9_StudioPack,代码行数:35,代码来源:Red9_PoseSaver.py

示例6: _buildPoseDict

    def _buildPoseDict(self, nodes):
        '''
        Build the internal poseDict up from the given nodes. This is the
        core of the Pose System
        '''
        if self.metaPose:
            getMetaDict=self.metaRig.getNodeConnectionMetaDataMap  # optimisation

        for i,node in enumerate(nodes):
            key=r9Core.nodeNameStrip(node)
            self.poseDict[key]={}
            self.poseDict[key]['ID']=i           # selection order index
            self.poseDict[key]['longName']=node  # longNode name
            
            if self.metaPose:
                self.poseDict[key]['metaData']=getMetaDict(node)  # metaSystem the node is wired too

            channels=r9Anim.getSettableChannels(node,incStatics=True)
            if channels:
                self.poseDict[key]['attrs']={}
                for attr in channels:
                    try:
                        if cmds.getAttr('%s.%s' % (node,attr),type=True)=='TdataCompound':  # blendShape weights support
                            attrs=cmds.aliasAttr(node, q=True)[::2]  # extract the target channels from the multi
                            for attr in attrs:
                                self.poseDict[key]['attrs'][attr]=cmds.getAttr('%s.%s' % (node,attr))
                        else:
                            self.poseDict[key]['attrs'][attr]=cmds.getAttr('%s.%s' % (node,attr))
                    except:
                        log.debug('%s : attr is invalid in this instance' % attr)
开发者ID:nicolasboselli,项目名称:test,代码行数:30,代码来源:Red9_PoseSaver.py

示例7: _buildOffsetCloud

    def _buildOffsetCloud(self,nodes,rootReference=None,raw=False):
        '''
        Build a point cloud up for each node in nodes
        @param nodes: list of objects to be in the cloud
        @param rootReference: the node used for the initial pibot location
        @param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
        '''
        self.posePointCloudNodes=[]

        self.posePointRoot=cmds.ls(cmds.spaceLocator(name='posePointCloud'),l=True)[0]   
        
        ppcShape=cmds.listRelatives(self.posePointRoot,type='shape')[0] 
        cmds.setAttr( "%s.localScaleZ" % ppcShape, 30)
        cmds.setAttr( "%s.localScaleX" % ppcShape, 30)
        cmds.setAttr( "%s.localScaleY" % ppcShape, 30)
        
        if self.mayaUpAxis=='y':
            cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
        if rootReference:# and not mesh:
            r9Anim.AnimFunctions.snap([rootReference,self.posePointRoot]) 
        for node in nodes:
            pnt=cmds.spaceLocator(name='pp_%s' % r9Core.nodeNameStrip(node))[0]
            if not raw:
                r9Anim.AnimFunctions.snap([node,pnt])
            cmds.parent(pnt,self.posePointRoot)
            self.posePointCloudNodes.append((pnt,node))
        return self.posePointCloudNodes
开发者ID:miketon,项目名称:SymLink,代码行数:27,代码来源:Red9_PoseSaver.py

示例8: formatAudioNode_to_Path

 def formatAudioNode_to_Path(self):
     '''
     rename the AudioNode so it ties to the wav name
     '''
     try:
         cmds.rename(self.audioNode, r9Core.nodeNameStrip(os.path.splitext(os.path.basename(self.path))[0]))
     except:
         log.debug('failed to Rename node : %s' % self.audioNode)
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:8,代码来源:Red9_Audio.py

示例9: formatAudioNode_to_Path

 def formatAudioNode_to_Path(self):
     '''
     rename the AudioNode so it ties to the wav name
     '''
     try:
         cmds.rename(self.audioNode, r9Core.nodeNameStrip(os.path.splitext(os.path.basename(self.path))[0]))
     except:
         if cmds.referenceQuery(self.audioNode,inr=True):
             log.info('failed to Rename Referenced Audio Node : %s' % self.audioNode)
         else:
             log.info('failed to Rename Audio node : %s' % self.audioNode)
开发者ID:satishgoda,项目名称:Red9_StudioPack,代码行数:11,代码来源:Red9_Audio.py

示例10: getAudioInRange

 def getAudioInRange(self, time=(), asNodes=True, start_inRange=True, end_inRange=True):
     '''
     return any audio in the handler within a given timerange
     
     :param time: tuple, (min,max) timerange within which returned audio has 
         fall within else it's ignored.
     :param asNodes: return the data as r9Audio.AudioNodes
     :param start_inRange: check is the testRange[0] value falls fully in the baseRange
     :param end_inRange: check is the testRange[1] value falls fully in the baseRange
 
     .. note::
         if you pass in time as (None, 100) then we only validate against the end time.
         if we pass in time as (10, None) we only validate against the start time
         else we validate that testRange is fully within the times
     '''
     audio_in_range=[]
     for a in self.audioNodes:
         if r9Core.timeIsInRange(time, (a.startFrame,a.endFrame), start_inRange=start_inRange, end_inRange=end_inRange):
             audio_in_range.append(a)
     if not asNodes:
         return [a.audioNode for a in audio_in_range]
     return audio_in_range
开发者ID:satishgoda,项目名称:Red9_StudioPack,代码行数:22,代码来源:Red9_Audio.py

示例11: _buildSkeletonData

 def _buildSkeletonData(self, rootJnt):
     '''
     :param rootNode: root of the skeleton to process
     '''
     self.skeletonDict={}
     if not rootJnt:
         log.info('skeleton rootJnt joint was not found')
         return
     
     fn=r9Core.FilterNode(rootJnt)
     fn.settings.nodeTypes='joint'
     fn.settings.incRoots=False
     skeleton=fn.ProcessFilter()
     
     for jnt in skeleton:
         key=r9Core.nodeNameStrip(jnt)
         self.skeletonDict[key]={}
         self.skeletonDict[key]['attrs']={}
         for attr in ['translateX','translateY','translateZ', 'rotateX','rotateY','rotateZ']:
             try:
                 self.skeletonDict[key]['attrs'][attr]=cmds.getAttr('%s.%s' % (jnt,attr))
             except:
                 log.debug('%s : attr is invalid in this instance' % attr)
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:23,代码来源:Red9_PoseSaver.py

示例12: _buildSkeletonData

    def _buildSkeletonData(self, rootJnt):
        """
        :param rootNode: root of the skeleton to process
        """
        self.skeletonDict = {}
        if not rootJnt:
            log.info("skeleton rootJnt joint was not found")
            return

        fn = r9Core.FilterNode(rootJnt)
        fn.settings.nodeTypes = "joint"
        fn.settings.incRoots = False
        skeleton = fn.ProcessFilter()

        for jnt in skeleton:
            key = r9Core.nodeNameStrip(jnt)
            self.skeletonDict[key] = {}
            self.skeletonDict[key]["attrs"] = {}
            for attr in ["translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ"]:
                try:
                    self.skeletonDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (jnt, attr))
                except:
                    log.debug("%s : attr is invalid in this instance" % attr)
开发者ID:vitattoo,项目名称:Red9_StudioPack,代码行数:23,代码来源:Red9_PoseSaver.py

示例13: compare

 def compare(self):
     '''
     Compare the 2 PoseData objects via their internal [key][attrs] blocks
     return a bool. After processing self.fails is a dict holding all the fails
     for processing later if required
     '''
     self.fails = {}
     logprint = 'PoseCompare returns : ========================================\n'
     currentDic = getattr(self.currentPose, self.compareDict)
     referenceDic = getattr(self.referencePose, self.compareDict)
     
     if not currentDic or not referenceDic:
         raise StandardError('missing pose section <<%s>> compare aborted' % self.compareDict)
     
     for key, attrBlock in currentDic.items():
         if self.filterMap and not key in self.filterMap:
             log.debug('node not in filterMap - skipping key %s' % key)
             continue
         if key in referenceDic:
             referenceAttrBlock = referenceDic[key]
         else:
             if not 'missingKeys' in self.ignoreBlocks:
                 logprint += 'ERROR: Key Mismatch : %s\n' % key
                 if not 'missingKeys' in self.fails:
                     self.fails['missingKeys'] = []
                 self.fails['missingKeys'].append(key)
             else:
                 log.debug('missingKeys in ignoreblock : node is missing from data but being skipped "%s"' % key)
             continue
         
         for attr, value in attrBlock['attrs'].items():
             # attr missing completely from the key
             if not attr in referenceAttrBlock['attrs']:
                 if not 'failedAttrs' in self.fails:
                     self.fails['failedAttrs'] = {}
                 if not key in self.fails['failedAttrs']:
                     self.fails['failedAttrs'][key] = {}
                 if not 'missingAttrs' in self.fails['failedAttrs'][key]:
                     self.fails['failedAttrs'][key]['missingAttrs'] = []
                 self.fails['failedAttrs'][key]['missingAttrs'].append(attr)
                 # log.info('missing attribute in data : "%s.%s"' % (key,attr))
                 logprint += 'ERROR: Missing attribute in data : "%s.%s"\n' % (key, attr)
                 continue
             
             # test the attrs value matches
             value = r9Core.decodeString(value)  # decode as this may be a configObj
             refValue = r9Core.decodeString(referenceAttrBlock['attrs'][attr])  # decode as this may be a configObj
             
             if type(value) == float:
                 matched = False
                 if attr in self.angularAttrs:
                     matched = r9Core.floatIsEqual(value, refValue, self.angularTolerance, allowGimbal=True)
                 else:
                     matched = r9Core.floatIsEqual(value, refValue, self.linearTolerance, allowGimbal=False)
                 if not matched:
                     self.__addFailedAttr(key, attr)
                     # log.info('AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                     logprint += 'ERROR: AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (key, attr, value, refValue)
                     continue
             elif not value == refValue:
                 self.__addFailedAttr(key, attr)
                 # log.info('AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                 logprint += 'ERROR: AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (key, attr, value, refValue)
                 continue
             
     if 'missingKeys' in self.fails or 'failedAttrs' in self.fails:
         logprint += 'PoseCompare returns : ========================================'
         print logprint
         return False
     self.status = True
     return True
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:71,代码来源:Red9_PoseSaver.py

示例14: poseLoad

    def poseLoad(self, nodes, filepath=None, useFilter=True, relativePose=False, relativeRots='projected',
                 relativeTrans='projected', maintainSpaces=False, percent=None):
        '''
        Entry point for the generic PoseLoad.
        
        :param nodes:  if given load the data to only these. If given and filter=True 
            this is the rootNode for the filter.
        :param filepath: posefile to load - if not given the pose is loaded from a 
            cached instance on this class.
        :param useFilter: If the pose has an active Filter_Settings block and this 
            is True then use the filter on the destination hierarchy.
        :param relativePose: kick in the posePointCloud to align the loaded pose 
            relatively to the selected node.
        :param relativeRots: 'projected' or 'absolute' - how to calculate the offset.
        :param relativeTrans: 'projected' or 'absolute' - how to calculate the offset.
        :param maintainSpaces: this preserves any parentSwitching mismatches between 
            the stored pose and the current rig settings, current spaces are maintained. 
            This only checks those nodes in the snapList and only runs under relative mode.
        '''
        
        if relativePose and not cmds.ls(sl=True):
            raise StandardError('Nothing selected to align Relative Pose too')
        if not type(nodes)==list:
            nodes=[nodes]  # cast to list for consistency
        
        #push args to object - means that any poseHandler.py file has access to them
        self.relativePose = relativePose
        self.relativeRots = relativeRots
        self.relativeTrans = relativeTrans
        self.PosePointCloud = None
        self.filepath = filepath
        self.useFilter = useFilter  # used in the getNodes call
        self.maintainSpaces = maintainSpaces
        
        nodesToLoad = self._poseLoad_buildcache(nodes)
        
        if not self.matchedPairs:
            raise StandardError('No Matching Nodes found in the PoseFile!')
        else:
            if self.relativePose:
                if self.prioritySnapOnly:
                    #we've already filtered the hierarchy, may as well just filter the results for speed
                    nodesToLoad=r9Core.prioritizeNodeList(nodesToLoad, self.settings.filterPriority, regex=True, prioritysOnly=True)
                    nodesToLoad.reverse()
                    
                #setup the PosePointCloud -------------------------------------------------
                reference=cmds.ls(sl=True,l=True)[0]
                self.PosePointCloud=PosePointCloud(nodesToLoad)
                self.PosePointCloud.buildOffsetCloud(reference, raw=True)
                resetCache=[cmds.getAttr('%s.translate' % self.PosePointCloud.posePointRoot),
                            cmds.getAttr('%s.rotate' % self.PosePointCloud.posePointRoot)]
                
                if self.maintainSpaces:
                    if self.metaRig:
                        parentSpaceCache=self.getMaintainedAttrs(nodesToLoad, self.metaRig.parentSwitchAttr)
                    elif 'parentSpaces' in self.settings.rigData:
                        parentSpaceCache=self.getMaintainedAttrs(nodesToLoad, self.settings.rigData['parentSpaces'])
    
            self._applyPose(percent)

            if self.relativePose:
                #snap the poseCloud to the new xform of the referenced node, snap the cloud
                #to the pose, reset the clouds parent to the cached xform and then snap the
                #nodes back to the cloud
                r9Anim.AnimFunctions.snap([reference,self.PosePointCloud.posePointRoot])
                 
                if self.relativeRots=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.rx' % self.PosePointCloud.posePointRoot,0)
                        cmds.setAttr('%s.rz' % self.PosePointCloud.posePointRoot,0)
                    elif self.mayaUpAxis=='z':  # fucking Z!!!!!!
                        cmds.setAttr('%s.rx' % self.PosePointCloud.posePointRoot,0)
                        cmds.setAttr('%s.ry' % self.PosePointCloud.posePointRoot,0)
                    
                self.PosePointCloud._snapPosePntstoNodes()
                
                if not self.relativeTrans=='projected':
                    cmds.setAttr('%s.translate' % self.PosePointCloud.posePointRoot,
                                 resetCache[0][0][0],
                                 resetCache[0][0][1],
                                 resetCache[0][0][2])
                if not self.relativeRots=='projected':
                    cmds.setAttr('%s.rotate' % self.PosePointCloud.posePointRoot,
                                 resetCache[1][0][0],
                                 resetCache[1][0][1],
                                 resetCache[1][0][2])
               
                if self.relativeRots=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.ry' % self.PosePointCloud.posePointRoot,resetCache[1][0][1])
                    elif self.mayaUpAxis=='z':  # fucking Z!!!!!!
                        cmds.setAttr('%s.rz' % self.PosePointCloud.posePointRoot,resetCache[1][0][2])
                if self.relativeTrans=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.tx' % self.PosePointCloud.posePointRoot,resetCache[0][0][0])
                        cmds.setAttr('%s.tz' % self.PosePointCloud.posePointRoot,resetCache[0][0][2])
                    elif self.mayaUpAxis=='z':  # fucking Z!!!!!!
                        cmds.setAttr('%s.tx' % self.PosePointCloud.posePointRoot,resetCache[0][0][0])
                        cmds.setAttr('%s.ty' % self.PosePointCloud.posePointRoot,resetCache[0][0][1])
                
#.........这里部分代码省略.........
开发者ID:santicolomo,项目名称:Red9_StudioPack,代码行数:101,代码来源:Red9_PoseSaver.py

示例15: compare

    def compare(self):
        """
        Compare the 2 PoseData objects via their internal [key][attrs] blocks
        return a bool. After processing self.fails is a dict holding all the fails
        for processing later if required
        """
        self.fails = {}
        logprint = "PoseCompare returns : ========================================\n"
        currentDic = getattr(self.currentPose, self.compareDict)
        referenceDic = getattr(self.referencePose, self.compareDict)

        if not currentDic or not referenceDic:
            raise StandardError("missing pose section <<%s>> compare aborted" % self.compareDict)

        for key, attrBlock in currentDic.items():
            if key in referenceDic:
                referenceAttrBlock = referenceDic[key]
            else:
                # log.info('Key Mismatch : %s' % key)
                logprint += "ERROR: Key Mismatch : %s\n" % key
                if not "missingKeys" in self.fails:
                    self.fails["missingKeys"] = []
                self.fails["missingKeys"].append(key)
                continue

            for attr, value in attrBlock["attrs"].items():
                # attr missing completely from the key
                if not attr in referenceAttrBlock["attrs"]:
                    if not "failedAttrs" in self.fails:
                        self.fails["failedAttrs"] = {}
                    if not key in self.fails["failedAttrs"]:
                        self.fails["failedAttrs"][key] = {}
                    if not "missingAttrs" in self.fails["failedAttrs"][key]:
                        self.fails["failedAttrs"][key]["missingAttrs"] = []
                    self.fails["failedAttrs"][key]["missingAttrs"].append(attr)
                    # log.info('missing attribute in data : "%s.%s"' % (key,attr))
                    logprint += 'ERROR: Missing attribute in data : "%s.%s"\n' % (key, attr)
                    continue

                # test the attrs value matches
                value = r9Core.decodeString(value)  # decode as this may be a configObj
                refValue = r9Core.decodeString(referenceAttrBlock["attrs"][attr])  # decode as this may be a configObj

                if type(value) == float:
                    matched = False
                    if attr in self.angularAttrs:
                        matched = r9Core.floatIsEqual(value, refValue, self.angularTolerance, allowGimbal=True)
                    else:
                        matched = r9Core.floatIsEqual(value, refValue, self.linearTolerance, allowGimbal=False)
                    if not matched:
                        self.__addFailedAttr(key, attr)
                        # log.info('AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                        logprint += (
                            'ERROR: AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n'
                            % (key, attr, value, refValue)
                        )
                        continue
                elif not value == refValue:
                    self.__addFailedAttr(key, attr)
                    # log.info('AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                    logprint += 'ERROR: AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (
                        key,
                        attr,
                        value,
                        refValue,
                    )
                    continue

        if "missingKeys" in self.fails or "failedAttrs" in self.fails:
            logprint += "PoseCompare returns : ========================================"
            print logprint
            return False
        self.status = True
        return True
开发者ID:vitattoo,项目名称:Red9_StudioPack,代码行数:74,代码来源:Red9_PoseSaver.py


注:本文中的Red9_CoreUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。