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


Python Red9_CoreUtils.decodeString方法代码示例

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


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

示例1: compare

# 需要导入模块: import Red9_CoreUtils [as 别名]
# 或者: from Red9_CoreUtils import decodeString [as 别名]
 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,代码行数:73,代码来源:Red9_PoseSaver.py

示例2: compare

# 需要导入模块: import Red9_CoreUtils [as 别名]
# 或者: from Red9_CoreUtils import decodeString [as 别名]
    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,代码行数:76,代码来源:Red9_PoseSaver.py


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