本文整理汇总了Python中arelle.XbrlUtil.attributes方法的典型用法代码示例。如果您正苦于以下问题:Python XbrlUtil.attributes方法的具体用法?Python XbrlUtil.attributes怎么用?Python XbrlUtil.attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.XbrlUtil
的用法示例。
在下文中一共展示了XbrlUtil.attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: equivalenceKey
# 需要导入模块: from arelle import XbrlUtil [as 别名]
# 或者: from arelle.XbrlUtil import attributes [as 别名]
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
示例2: checkFacts
# 需要导入模块: from arelle import XbrlUtil [as 别名]
# 或者: from arelle.XbrlUtil import attributes [as 别名]
#.........这里部分代码省略.........
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)
示例3: validate
# 需要导入模块: from arelle import XbrlUtil [as 别名]
# 或者: from arelle.XbrlUtil import attributes [as 别名]
#.........这里部分代码省略.........
_("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 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):
self.footnoteRefs.update(f.footnoteRefs)
#instance checks
for cntx in modelXbrl.contexts.values():
if cntx.isStartEndPeriod:
try:
if cntx.endDatetime <= cntx.startDatetime:
self.modelXbrl.error("xbrl.4.7.2:periodStartBeforeEnd",
_("Context %(contextID)s must have startDate less than endDate"),
modelObject=cntx, contextID=cntx.id)
except (TypeError, ValueError) as err:
self.modelXbrl.error("xbrl.4.7.2:contextDateError",
_("Context %(contextID) startDate or endDate: %(error)s"),
modelObject=cntx, contextID=cntx.id, error=err)
elif cntx.isInstantPeriod:
try:
cntx.instantDatetime #parse field
except ValueError as err:
self.modelXbrl.error("xbrl.4.7.2:contextDateError",
_("Context %(contextID)s instant date: %(error)s"),
modelObject=cntx, contextID=cntx.id, error=err)
self.segmentScenario(cntx.segment, cntx.id, "segment", "4.7.3.2")