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


Python arelle.XbrlUtil类代码示例

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


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

示例1: nonDimHash

 def nonDimHash(self):
     try:
         return self._nonDimsHash
     except AttributeError:
         self._nonDimsHash = hash( (XbrlUtil.equalityHash(self.nonDimValues("segment")), 
                                    XbrlUtil.equalityHash(self.nonDimValues("scenario"))) )
         return self._nonDimsHash
开发者ID:Bourne-Law,项目名称:Arelle,代码行数:7,代码来源:ModelInstanceObject.py

示例2: isEqualTo_

 def isEqualTo_(self, cntx2, dimensionalAspectModel):
     """(bool) -- If dimensionalAspectModel is absent, True is assumed.  
     False means comparing based on s-equality of segment, scenario, while 
     True means based on dimensional values and nonDimensional values separately."""
     if cntx2 is None:
         return False
     if cntx2 == self:   # same context
         return True
     if (self.periodHash != cntx2.periodHash or
         self.entityIdentifierHash != cntx2.entityIdentifierHash):
         return False 
     if dimensionalAspectModel:
         if (self.dimsHash != cntx2.dimsHash or
             self.nonDimHash != cntx2.nonDimHash):
             return False
     else:
         if (self.segmentHash != cntx2.segmentHash or
             self.scenarioHash != cntx2.scenarioHash):
             return False
     if self.periodHash != cntx2.periodHash or not self.isPeriodEqualTo(cntx2) or not self.isEntityIdentifierEqualTo(cntx2):
         return False
     if dimensionalAspectModel:
         if _DICT_SET(self.qnameDims.keys()) != _DICT_SET(cntx2.qnameDims.keys()):
             return False
         for dimQname, ctx1Dim in self.qnameDims.items():
             if not ctx1Dim.isEqualTo(cntx2.qnameDims[dimQname]):
                 return False
         for nonDimVals1, nonDimVals2 in ((self.segNonDimValues,cntx2.segNonDimValues),
                                          (self.scenNonDimValues,cntx2.scenNonDimValues)):
             if len(nonDimVals1) !=  len(nonDimVals2):
                 return False
             for i, nonDimVal1 in enumerate(nonDimVals1):
                 if not XbrlUtil.sEqual(self.modelXbrl, nonDimVal1, nonDimVals2[i]):
                     return False                    
     else:
         if self.hasSegment:
             if not cntx2.hasSegment:
                 return False
             if not XbrlUtil.sEqual(self.modelXbrl, self.segment, cntx2.segment):
                 return False
         elif cntx2.hasSegment:
             return False
 
         if self.hasScenario:
             if not cntx2.hasScenario:
                 return False
             if not XbrlUtil.sEqual(self.modelXbrl, self.scenario, cntx2.scenario):
                 return False
         elif cntx2.hasScenario:
             return False
     
     return True
开发者ID:lmsanch,项目名称:Arelle,代码行数:52,代码来源:ModelInstanceObject.py

示例3: isEqualTo_

 def isEqualTo_(self, cntx2, dimensionalAspectModel):
     if cntx2 is None:
         return False
     if cntx2 == self:   # same context
         return True
     if (self.periodHash != cntx2.periodHash or
         self.entityIdentifierHash != cntx2.entityIdentifierHash):
         return False 
     if dimensionalAspectModel:
         if (self.dimsHash != cntx2.dimsHash or
             self.nonDimHash != cntx2.nonDimHash):
             return False
     else:
         if (self.segmentHash != cntx2.segmentHash or
             self.scenarioHash != cntx2.scenarioHash):
             return False
     if self.periodHash != cntx2.periodHash or not self.isPeriodEqualTo(cntx2) or not self.isEntityIdentifierEqualTo(cntx2):
         return False
     if dimensionalAspectModel:
         if self.qnameDims.keys() != cntx2.qnameDims.keys():
             return False
         for dimQname, ctx1Dim in self.qnameDims.items():
             if not ctx1Dim.isEqualTo(cntx2.qnameDims[dimQname]):
                 return False
         for nonDimVals1, nonDimVals2 in ((self.segNonDimValues,cntx2.segNonDimValues),
                                          (self.scenNonDimValues,cntx2.scenNonDimValues)):
             if len(nonDimVals1) !=  len(nonDimVals2):
                 return False
             for i, nonDimVal1 in enumerate(nonDimVals1):
                 if not XbrlUtil.sEqual(self.modelXbrl, nonDimVal1, nonDimVals2[i]):
                     return False                    
     else:
         if self.hasSegment:
             if not cntx2.hasSegment:
                 return False
             if not XbrlUtil.sEqual(self.modelXbrl, self.segment, cntx2.segment):
                 return False
         elif cntx2.hasSegment:
             return False
 
         if self.hasScenario:
             if not cntx2.hasScenario:
                 return False
             if not XbrlUtil.sEqual(self.modelXbrl, self.scenario, cntx2.scenario):
                 return False
         elif cntx2.hasScenario:
             return False
     
     return True
开发者ID:marado,项目名称:Arelle,代码行数:49,代码来源:ModelInstanceObject.py

示例4: nonDimScenarioHash

 def nonDimScenarioHash(self):
     """(int) -- Hash, of s-equality values, of non-XDT scenario objects"""
     try:
         return self._nonDimScenarioHash
     except AttributeError:
         self._nonDimScenarioHash = XbrlUtil.equalityHash(self.nonDimValues("scenario"))
         return self._nonDimScenarioHash
开发者ID:lmsanch,项目名称:Arelle,代码行数:7,代码来源:ModelInstanceObject.py

示例5: s_equal_test

def s_equal_test(node1, node2):
    if (isinstance(node1, (ModelFact, ModelInlineFact)) and node1.isItem and
        isinstance(node2, (ModelFact, ModelInlineFact)) and node2.isItem):
        return (c_equal_test(node1, node2) and u_equal_test(node1, node2) and
                XbrlUtil.xEqual(node1, node2) and 
                # must be validated (by xEqual) before precision tests to assure xAttributes is set
                node1.xAttributes.get("precision") == node2.xAttributes.get("precision") and
                node1.xAttributes.get("decimals") == node2.xAttributes.get("decimals"))
    elif isinstance(node1, ModelObject):
        if isinstance(node2, ModelObject):
            return XbrlUtil.sEqual(node1.modelXbrl, node1, node2, excludeIDs=XbrlUtil.TOP_IDs_EXCLUDED, dts2=node2.modelXbrl)
        else:
            return False
    elif isinstance(node1, ModelAttribute):
        if isinstance(node2, ModelAttribute):
            return node1.text == node2.text
    return False
开发者ID:marado,项目名称:Arelle,代码行数:17,代码来源:FunctionXfi.py

示例6: nodes_correspond

def nodes_correspond(xc, p, args):
    if len(args) != 2: raise XPathContext.FunctionNumArgs()
    node1 = nodeArg(xc, args, 0, "node()?", missingArgFallback=(), emptyFallback=())
    node2 = nodeArg(xc, args, 1, "node()?", missingArgFallback=(), emptyFallback=())
    if node1 == ():
        if node2 == (): return True
        return False
    if node2 == (): return False
    return XbrlUtil.nodesCorrespond(xc.modelXbrl, node1, node2, xc.modelXbrl)
开发者ID:marado,项目名称:Arelle,代码行数:9,代码来源:FunctionXfi.py

示例7: x_equal_test

def x_equal_test(node1, node2):
    if isinstance(node1, ModelObject):
        if isinstance(node2, ModelObject):
            return XbrlUtil.xEqual(node1, node2)
        else:
            return False
    elif isinstance(node1, ModelAttribute):
        if isinstance(node2, ModelAttribute):
            return node1.sValue == node2.sValue
    return False
开发者ID:marado,项目名称:Arelle,代码行数:10,代码来源:FunctionXfi.py

示例8: isEqualTo

 def isEqualTo(self, other, equalMode=XbrlUtil.XPATH_EQ):
     if isinstance(other, ModelValue.QName):
         return self.isExplicit and self.memberQname == other
     elif other is None:
         return False
     elif self.isExplicit:
         return self.memberQname == other.memberQname
     else:
         return XbrlUtil.nodesCorrespond(self.modelXbrl, self.typedMember, other.typedMember, 
                                         equalMode=equalMode, excludeIDs=XbrlUtil.NO_IDs_EXCLUDED)
开发者ID:jaolguin,项目名称:Arelle,代码行数:10,代码来源:ModelInstanceObject.py

示例9: equivalenceKey

 def equivalenceKey(self):
     # cannot be cached because this is unique per relationship
     return (self.qname, 
             self.linkQname,
             self.linkrole,  # needed when linkrole=None merges multiple links
             self.fromModelObject.objectIndex if self.fromModelObject is not None else -1, 
             self.toModelObject.objectIndex if self.toModelObject is not None else -1,
             self.order, 
             self.weight, 
             self.preferredLabel) + \
             XbrlUtil.attributes(self.modelXbrl, self.arcElement, 
                 exclusions=arcCustAttrsExclusions, keyByTag=True) # use clark tag for key instead of qname
开发者ID:marado,项目名称:Arelle,代码行数:12,代码来源:ModelDtsObject.py

示例10: isEqualTo

 def isEqualTo(self, other, equalMode=XbrlUtil.XPATH_EQ):
     """(bool) -- True if explicit member QNames equal or typed member nodes correspond, given equalMode (s-equal, s-equal2, or xpath-equal for formula)
     
     :param equalMode: XbrlUtil.S_EQUAL (ordinary S-equality from 2.1 spec), XbrlUtil.S_EQUAL2 (XDT definition of equality, adding QName comparisions), or XbrlUtil.XPATH_EQ (XPath EQ on all types)
     """
     if other is None:
         return False
     if self.isExplicit: # other is either ModelDimensionValue or the QName value of explicit dimension
         return self.memberQname == (other.memberQname if isinstance(other, (ModelDimensionValue,DimValuePrototype)) else other)
     else: # typed dimension compared to another ModelDimensionValue or other is the value nodes
         return XbrlUtil.nodesCorrespond(self.modelXbrl, self.typedMember, 
                                         other.typedMember if isinstance(other, (ModelDimensionValue,DimValuePrototype)) else other, 
                                         equalMode=equalMode, excludeIDs=XbrlUtil.NO_IDs_EXCLUDED)
开发者ID:lmsanch,项目名称:Arelle,代码行数:13,代码来源:ModelInstanceObject.py

示例11: checkFacts


#.........这里部分代码省略.........
             if concept.isItem:
                 context = f.context
                 if context is None:
                     self.modelXbrl.error("xbrl.4.6.1:itemContextRef",
                         _("Item %(fact)s must have a context"),
                         modelObject=f, fact=f.qname)
                 else:
                     periodType = concept.periodType
                     if (periodType == "instant" and not context.isInstantPeriod) or \
                        (periodType == "duration" and not (context.isStartEndPeriod or context.isForeverPeriod)):
                         self.modelXbrl.error("xbrl.4.7.2:contextPeriodType",
                             _("Fact %(fact)s context %(contextID)s has period type %(periodType)s conflict with context"),
                             modelObject=f, fact=f.qname, contextID=f.contextID, periodType=periodType)
                         
                 # check precision and decimals
                 if f.xsiNil == "true":
                     if hasPrecision or hasDecimals:
                         self.modelXbrl.error("xbrl.4.6.3:nilPrecisionDecimals",
                             _("Fact %(fact)s context %(contextID)s can not be nil and have either precision or decimals"),
                             modelObject=f, fact=f.qname, contextID=f.contextID)
                 elif concept.isFraction:
                     if hasPrecision or hasDecimals:
                         self.modelXbrl.error("xbrl.4.6.3:fractionPrecisionDecimals",
                             _("Fact %(fact)s context %(contextID)s is a fraction concept and cannot have either precision or decimals"),
                             modelObject=f, fact=f.qname, contextID=f.contextID)
                         numerator, denominator = f.fractionValue
                         if not (numerator == "INF" or numerator.isnumeric()):
                             self.modelXbrl.error("xbrl.5.1.1:fractionPrecisionDecimals",
                                 _("Fact %(fact)s context %(contextID)s is a fraction with invalid numerator %(numerator)s"),
                                 modelObject=f, fact=f.qname, contextID=f.contextID, numerator=numerator)
                         if not denominator.isnumeric() or _INT(denominator) == 0:
                             self.modelXbrl.error("xbrl.5.1.1:fractionPrecisionDecimals",
                                 _("Fact %(fact)s context %(contextID)s is a fraction with invalid denominator %(denominator)")).format(
                                 modelObject=f, fact=f.qname, contextID=f.contextID, denominator=denominator)
                 else:
                     if self.modelXbrl.modelDocument.type != ModelDocument.Type.INLINEXBRL:
                         for child in f.iterchildren():
                             if isinstance(child,ModelObject):
                                 self.modelXbrl.error("xbrl.5.1.1:itemMixedContent",
                                     _("Fact %(fact)s context %(contextID)s may not have child elements %(childElementName)s"),
                                     modelObject=f, fact=f.qname, contextID=f.contextID, childElementName=child.prefixedName)
                                 break
                     if concept.isNumeric and not hasPrecision and not hasDecimals:
                         self.modelXbrl.error("xbrl.4.6.3:missingPrecisionDecimals",
                             _("Fact %(fact)s context %(contextID)s is a numeric concept and must have either precision or decimals"),
                             modelObject=f, fact=f.qname, contextID=f.contextID)
             elif concept.isTuple:
                 if f.contextID:
                     self.modelXbrl.error("xbrl.4.6.1:tupleContextRef",
                         _("Tuple %(fact)s must not have a context"),
                         modelObject=f, fact=f.qname)
                 if hasPrecision or hasDecimals:
                     self.modelXbrl.error("xbrl.4.6.3:tuplePrecisionDecimals",
                         _("Fact %(fact)s is a tuple and cannot have either precision or decimals"),
                         modelObject=f, fact=f.qname)
                 # custom attributes may be allowed by anyAttribute but not by 2.1
                 for attrQname, attrValue in XbrlUtil.attributes(self.modelXbrl, f):
                     if attrQname.namespaceURI in (XbrlConst.xbrli, XbrlConst.link, XbrlConst.xlink, XbrlConst.xl):
                         self.modelXbrl.error(_("xbrl.4.9:tupleAttribute"),
                             _("Fact %(fact)s is a tuple and must not have attribute in this namespace %(attribute)s"),
                             modelObject=f, fact=f.qname, attribute=attrQname), 
             else:
                 self.modelXbrl.error("xbrl.4.6:notItemOrTuple",
                     _("Fact %(fact)s must be an item or tuple"),
                     modelObject=f, fact=f.qname)
                 
         if isinstance(f, ModelInlineFact):
             if concept is None:
                 self.modelXbrl.error("xbrl:schemaImportMissing",
                         _("Fact %(fact)s missing schema definition or missing name attribute"),
                         modelObject=f, fact=f.qname)
             if f.localName in {"fraction", "nonFraction", "nonNumeric"} and not f.contextID:
                 self.modelXbrl.error("ix:missingContextRef",
                     _("Fact %(fact)s is missing a contextRef"),
                     modelObject=f, fact=f.qname)
             if f.localName in {"fraction", "nonFraction"} and not f.unitID:
                 self.modelXbrl.error("ix:missingUnitRef",
                     _("Fact %(fact)s is missing a unitRef"),
                     modelObject=f, fact=f.qname)
             self.footnoteRefs.update(f.footnoteRefs)
             fmt = f.format
             if fmt:
                 if fmt.namespaceURI not in FunctionIxt.ixtNamespaceURIs:
                     self.modelXbrl.error("ix.14.2:invalidTransformation",
                         _("Fact %(fact)s has unrecognized transformation namespace %(namespace)s"),
                         modelObject=f, fact=f.qname, namespace=fmt.namespaceURI)
                 elif fmt.localName not in FunctionIxt.ixtFunctions:
                     self.modelXbrl.error("ix.14.2:invalidTransformation",
                         _("Fact %(fact)s has unrecognized transformation name %(name)s"),
                         modelObject=f, fact=f.qname, name=fmt.localName)
                 if fmt.namespaceURI == FunctionIxt.deprecatedNamespaceURI:
                     self.factsWithDeprecatedIxNamespace.append(f)
             if f.isTuple or f.tupleID:
                 self.checkIxTupleContent(f, set())
             if not inTuple and f.order is not None: 
                 self.modelXbrl.error("ix.13.1.2:tupleOrder",
                     _("Fact %(fact)s must not have an order (%(order)s) unless in a tuple"),
                     modelObject=f, fact=f.qname, order=f.order)
         if f.modelTupleFacts:
             self.checkFacts(f.modelTupleFacts, inTuple=True)
开发者ID:ojones20,项目名称:Arelle,代码行数:101,代码来源:ValidateXbrl.py

示例12: scenarioHash

 def scenarioHash(self):
     """(int) -- Hash of the scenario, based on s-equality values"""
     return XbrlUtil.equalityHash( self.scenario ) # self-caching
开发者ID:lmsanch,项目名称:Arelle,代码行数:3,代码来源:ModelInstanceObject.py

示例13: segmentHash

 def segmentHash(self):
     """(int) -- Hash of the segment, based on s-equality values"""
     return XbrlUtil.equalityHash( self.segment ) # self-caching
开发者ID:lmsanch,项目名称:Arelle,代码行数:3,代码来源:ModelInstanceObject.py

示例14: validate


#.........这里部分代码省略.........
                            for modelRel in modelRels:
                                itemConcept = modelRel.toModelObject
                                if itemConcept is not None and itemConcept.qname is not None:
                                    itemBindingKeys = self.itemConceptBindKeys[itemConcept]
                                    boundSumKeys |= sumBindingKeys & itemBindingKeys
                            # add up rounded items
                            boundSums = defaultdict(decimal.Decimal) # sum of facts meeting factKey
                            boundSummationItems = defaultdict(list) # corresponding fact refs for messages
                            for modelRel in modelRels:
                                weight = modelRel.weightDecimal
                                itemConcept = modelRel.toModelObject
                                if itemConcept is not None:
                                    for itemBindKey in boundSumKeys:
                                        ancestor, contextHash, unit = itemBindKey
                                        factKey = (itemConcept, ancestor, contextHash, unit)
                                        if factKey in self.itemFacts:
                                            for fact in self.itemFacts[factKey]:
                                                if fact in self.duplicatedFacts:
                                                    dupBindingKeys.add(itemBindKey)
                                                else:
                                                    roundedValue = roundFact(fact, self.inferDecimals)
                                                    boundSums[itemBindKey] += roundedValue * weight
                                                    boundSummationItems[itemBindKey].append(wrappedFactWithWeight(fact,weight,roundedValue))
                            for sumBindKey in boundSumKeys:
                                ancestor, contextHash, unit = sumBindKey
                                factKey = (sumConcept, ancestor, contextHash, unit)
                                if factKey in self.sumFacts:
                                    sumFacts = self.sumFacts[factKey]
                                    for fact in sumFacts:
                                        if fact in self.duplicatedFacts:
                                            dupBindingKeys.add(sumBindKey)
                                        elif sumBindKey not in dupBindingKeys:
                                            roundedSum = roundFact(fact, self.inferDecimals)
                                            roundedItemsSum = roundFact(fact, self.inferDecimals, vDecimal=boundSums[sumBindKey])
                                            if roundedItemsSum  != roundFact(fact, self.inferDecimals):
                                                d = inferredDecimals(fact)
                                                if isnan(d) or isinf(d): d = 4
                                                _boundSummationItems = boundSummationItems[sumBindKey]
                                                unreportedContribingItemQnames = [] # list the missing/unreported contributors in relationship order
                                                for modelRel in modelRels:
                                                    itemConcept = modelRel.toModelObject
                                                    if (itemConcept is not None and 
                                                        (itemConcept, ancestor, contextHash, unit) not in self.itemFacts):
                                                        unreportedContribingItemQnames.append(str(itemConcept.qname))
                                                self.modelXbrl.log('INCONSISTENCY', "xbrl.5.2.5.2:calcInconsistency",
                                                    _("Calculation inconsistent from %(concept)s in link role %(linkrole)s reported sum %(reportedSum)s computed sum %(computedSum)s context %(contextID)s unit %(unitID)s unreportedContributingItems %(unreportedContributors)s"),
                                                    modelObject=wrappedSummationAndItems(fact, roundedSum, _boundSummationItems),
                                                    concept=sumConcept.qname, linkrole=ELR, 
                                                    linkroleDefinition=self.modelXbrl.roleTypeDefinition(ELR),
                                                    reportedSum=Locale.format_decimal(self.modelXbrl.locale, roundedSum, 1, max(d,0)),
                                                    computedSum=Locale.format_decimal(self.modelXbrl.locale, roundedItemsSum, 1, max(d,0)), 
                                                    contextID=fact.context.id, unitID=fact.unit.id,
                                                    unreportedContributors=", ".join(unreportedContribingItemQnames) or "none")
                                                del unreportedContribingItemQnames[:]
                            boundSummationItems.clear() # dereference facts in list
                    elif arcrole == XbrlConst.essenceAlias:
                        for modelRel in relsSet.modelRelationships:
                            essenceConcept = modelRel.fromModelObject
                            aliasConcept = modelRel.toModelObject
                            essenceBindingKeys = self.esAlConceptBindKeys[essenceConcept]
                            aliasBindingKeys = self.esAlConceptBindKeys[aliasConcept]
                            for esAlBindKey in essenceBindingKeys & aliasBindingKeys:
                                ancestor, contextHash = esAlBindKey
                                essenceFactsKey = (essenceConcept, ancestor, contextHash)
                                aliasFactsKey = (aliasConcept, ancestor, contextHash)
                                if essenceFactsKey in self.esAlFacts and aliasFactsKey in self.esAlFacts:
                                    for eF in self.esAlFacts[essenceFactsKey]:
                                        for aF in self.esAlFacts[aliasFactsKey]:
                                            essenceUnit = self.mapUnit.get(eF.unit,eF.unit)
                                            aliasUnit = self.mapUnit.get(aF.unit,aF.unit)
                                            if essenceUnit != aliasUnit:
                                                self.modelXbrl.log('INCONSISTENCY', "xbrl.5.2.6.2.2:essenceAliasUnitsInconsistency",
                                                    _("Essence-Alias inconsistent units from %(essenceConcept)s to %(aliasConcept)s in link role %(linkrole)s context %(contextID)s"),
                                                    modelObject=(modelRel, eF, aF), 
                                                    essenceConcept=essenceConcept.qname, aliasConcept=aliasConcept.qname, 
                                                    linkrole=ELR, 
                                                    linkroleDefinition=self.modelXbrl.roleTypeDefinition(ELR),
                                                    contextID=eF.context.id)
                                            if not XbrlUtil.vEqual(eF, aF):
                                                self.modelXbrl.log('INCONSISTENCY', "xbrl.5.2.6.2.2:essenceAliasUnitsInconsistency",
                                                    _("Essence-Alias inconsistent value from %(essenceConcept)s to %(aliasConcept)s in link role %(linkrole)s context %(contextID)s"),
                                                    modelObject=(modelRel, eF, aF), 
                                                    essenceConcept=essenceConcept.qname, aliasConcept=aliasConcept.qname, 
                                                    linkrole=ELR,
                                                    linkroleDefinition=self.modelXbrl.roleTypeDefinition(ELR),
                                                    contextID=eF.context.id)
                    elif arcrole == XbrlConst.requiresElement:
                        for modelRel in relsSet.modelRelationships:
                            sourceConcept = modelRel.fromModelObject
                            requiredConcept = modelRel.toModelObject
                            if sourceConcept in self.requiresElementFacts and \
                               not requiredConcept in self.requiresElementFacts:
                                    self.modelXbrl.log('INCONSISTENCY', "xbrl.5.2.6.2.4:requiresElementInconsistency",
                                        _("Requires-Element %(requiringConcept)s missing required fact for %(requiredConcept)s in link role %(linkrole)s"),
                                        modelObject=sourceConcept, 
                                        requiringConcept=sourceConcept.qname, requiredConcept=requiredConcept.qname, 
                                        linkrole=ELR,
                                        linkroleDefinition=self.modelXbrl.roleTypeDefinition(ELR))
        self.modelXbrl.profileActivity("... find inconsistencies", minTimeToShow=1.0)
        self.modelXbrl.profileActivity() # reset
开发者ID:JTYim,项目名称:Arelle,代码行数:101,代码来源:ValidateXbrlCalcs.py

示例15: validate


#.........这里部分代码省略.........
                            for modelRel in modelRels:
                                itemBindingKeys = self.itemConceptBindKeys[modelRel.toModelObject]
                                boundSumKeys |= sumBindingKeys & itemBindingKeys
                            # add up rounded items
                            boundSums = defaultdict(decimal.Decimal)
                            for modelRel in modelRels:
                                weight = modelRel.weightDecimal
                                itemConcept = modelRel.toModelObject
                                for itemBindKey in boundSumKeys:
                                    ancestor, contextHash, unit = itemBindKey
                                    factKey = (itemConcept, ancestor, contextHash, unit)
                                    if factKey in self.itemFacts:
                                        for fact in self.itemFacts[factKey]:
                                            if fact in self.duplicatedFacts:
                                                dupBindingKeys.add(itemBindKey)
                                            else:
                                                boundSums[itemBindKey] += self.roundFact(fact) * weight
                            for sumBindKey in boundSumKeys:
                                ancestor, contextHash, unit = sumBindKey
                                factKey = (sumConcept, ancestor, contextHash, unit)
                                if factKey in self.sumFacts:
                                    for fact in self.sumFacts[factKey]:
                                        if fact in self.duplicatedFacts:
                                            dupBindingKeys.add(sumBindKey)
                                        elif sumBindKey not in dupBindingKeys:
                                            roundedSum = self.roundFact(fact)
                                            roundedItemsSum = self.roundFact(fact, vDecimal=boundSums[sumBindKey])
                                            if roundedItemsSum != self.roundFact(fact):
                                                self.modelXbrl.error(
                                                    "xbrl.5.2.5.2:calcInconsistency",
                                                    _(
                                                        "Calculation inconsistent from %(concept)s in link role %(linkrole)s reported sum %(reportedSum)s computed sum %(computedSum)s context %(contextID)s unit %(unitID)s"
                                                    ),
                                                    modelObject=sumConcept,
                                                    concept=sumConcept.qname,
                                                    linkrole=ELR,
                                                    reportedSum=roundedSum,
                                                    computedSum=roundedItemsSum,
                                                    contextID=context.id,
                                                    unitID=unit.id,
                                                )
                    elif arcrole == XbrlConst.essenceAlias:
                        for modelRel in relsSet.modelRelationships:
                            essenceConcept = modelRel.fromModelObject
                            aliasConcept = modelRel.toModelObject
                            essenceBindingKeys = self.esAlConceptBindKeys[essenceConcept]
                            aliasBindingKeys = self.esAlConceptBindKeys[aliasConcept]
                            for esAlBindKey in essenceBindingKeys & aliasBindingKeys:
                                ancestor, contextHash = esAlBindKey
                                essenceFactsKey = (essenceConcept, ancestor, contextHash)
                                aliasFactsKey = (aliasConcept, ancestor, contextHash)
                                if essenceFactsKey in self.esAlFacts and aliasFactsKey in self.esAlFacts:
                                    for eF in self.esAlFacts[essenceFactsKey]:
                                        for aF in self.esAlFacts[aliasFactsKey]:
                                            essenceUnit = self.mapUnit.get(eF.unit, eF.unit)
                                            aliasUnit = self.mapUnit.get(aF.unit, aF.unit)
                                            if essenceUnit != aliasUnit:
                                                self.modelXbrl.error(
                                                    "xbrl.5.2.6.2.2:essenceAliasUnitsInconsistency",
                                                    _(
                                                        "Essence-Alias inconsistent units from %(essenceConcept)s to %(aliasConcept)s in link role %(linkrole)s context %(contextID)s"
                                                    ),
                                                    modelObject=essenceConcept,
                                                    essenceConcept=essenceConcept.qname,
                                                    aliasConcept=aliasConcept.qname,
                                                    linkrole=ELR,
                                                    contextID=context.id,
                                                )
                                            if not XbrlUtil.vEqual(eF, aF):
                                                self.modelXbrl.error(
                                                    "xbrl.5.2.6.2.2:essenceAliasUnitsInconsistency",
                                                    _(
                                                        "Essence-Alias inconsistent value from %(essenceConcept)s to %(aliasConcept)s in link role %(linkrole)s context %(contextID)s"
                                                    ),
                                                    modelObject=essenceConcept,
                                                    essenceConcept=essenceConcept.qname,
                                                    aliasConcept=aliasConcept.qname,
                                                    linkrole=ELR,
                                                    contextID=context.id,
                                                )
                    elif arcrole == XbrlConst.requiresElement:
                        for modelRel in relsSet.modelRelationships:
                            sourceConcept = modelRel.fromModelObject
                            requiredConcept = modelRel.toModelObject
                            if (
                                sourceConcept in self.requiresElementFacts
                                and not requiredConcept in self.requiresElementFacts
                            ):
                                self.modelXbrl.error(
                                    "xbrl.5.2.6.2.4:requiresElementInconsistency",
                                    _(
                                        "Requires-Element %(requiringConcept)s missing required fact for %(requiredConcept)s in link role %(linkrole)s"
                                    ),
                                    modelObject=sourceConcept,
                                    requiringConcept=sourceConcept.qname,
                                    requiredConcept=requiredConcept.qname,
                                    linkrole=ELR,
                                )
        self.modelXbrl.profileActivity("... find inconsistencies", minTimeToShow=1.0)
        self.modelXbrl.profileActivity()  # reset
开发者ID:marado,项目名称:Arelle,代码行数:101,代码来源:ValidateXbrlCalcs.py


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