本文整理汇总了Python中arelle.UrlUtil.splitDecodeFragment方法的典型用法代码示例。如果您正苦于以下问题:Python UrlUtil.splitDecodeFragment方法的具体用法?Python UrlUtil.splitDecodeFragment怎么用?Python UrlUtil.splitDecodeFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.UrlUtil
的用法示例。
在下文中一共展示了UrlUtil.splitDecodeFragment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkConcept
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def checkConcept(val, concept):
if concept.element.hasAttributeNS(XbrlConst.xbrldt, "typedDomainRef"):
if concept.isDimensionItem:
typedDomainElement = concept.typedDomainElement
if typedDomainElement is None:
url, id = UrlUtil.splitDecodeFragment(concept.element.getAttributeNS(XbrlConst.xbrldt, "typedDomainRef"))
if len(id) == 0:
val.modelXbrl.error(
_("Concept {0} typedDomainRef has no fragment identifier").format(
concept.qname),
"err", "xbrldte:TypedDimensionURIError")
else:
val.modelXbrl.error(
_("Concept {0} typedDomainRef is not resolved").format(
concept.qname),
"err", "xbrldte:OutOfDTSSchemaError")
elif not isinstance(typedDomainElement, ModelObject.ModelConcept) or \
not typedDomainElement.isGlobalDeclaration or \
typedDomainElement.abstract == "true":
val.modelXbrl.error(
_("Concept {0} typedDomainRef must identify a non-abstract element").format(
concept.qname),
"err", "xbrldte:TypedDimensionError")
else:
val.modelXbrl.error(
_("Concept {0} is not a dimension item but has a typedDomainRef").format(
concept.qname),
"err", "xbrldte:TypedDomainRefError")
示例2: resolveUri
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def resolveUri(self, hrefObject=None, uri=None, dtsModelXbrl=None):
if dtsModelXbrl is None:
dtsModelXbrl = self.modelXbrl
doc = None
if hrefObject:
hrefElt,doc,id = hrefObject
elif uri:
from arelle import UrlUtil
url, id = UrlUtil.splitDecodeFragment(uri)
if url == "":
doc = self.modelDocument
else:
normalizedUrl = self.modelXbrl.modelManager.cntlr.webCache.normalizeUrl(
url,
self.modelDocument.baseForElement(self))
doc = dtsModelXbrl.urlDocs.get(normalizedUrl)
from arelle import ModelDocument
if isinstance(doc, ModelDocument.ModelDocument):
if id is None:
return doc
elif id in doc.idObjects:
return doc.idObjects[id]
else:
from arelle.XmlUtil import xpointerElement
xpointedElement = xpointerElement(doc,id)
# find element
for docModelObject in doc.modelObjects:
if docModelObject == xpointedElement:
doc.idObjects[id] = docModelObject # cache for reuse
return docModelObject
return None
示例3: discoverHref
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def discoverHref(self, element, nonDTS=False):
if element.hasAttributeNS(XbrlConst.xlink, "href"):
url, id = UrlUtil.splitDecodeFragment(element.getAttributeNS(XbrlConst.xlink, "href"))
if url == "":
doc = self
else:
doc = load(self.modelXbrl, url, base=self.baseForElement(element))
if not nonDTS and doc is not None and self.referencesDocument.get(doc) is None:
self.referencesDocument[doc] = "href"
doc.inDTS = doc.type != Type.Unknown # non-XBRL document is not in DTS
href = (element, doc, id if len(id) > 0 else None)
self.hrefObjects.append(href)
return href
return None
示例4: discoverHref
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def discoverHref(self, element, nonDTS=False):
href = element.get("{http://www.w3.org/1999/xlink}href")
if href:
url, id = UrlUtil.splitDecodeFragment(href)
if url == "":
doc = self
else:
# href discovery only can happein within a DTS
doc = load(self.modelXbrl, url, isDiscovered=not nonDTS, base=self.baseForElement(element), referringElement=element)
if not nonDTS and doc is not None and self.referencesDocument.get(doc) is None:
self.referencesDocument[doc] = "href"
if not doc.inDTS and doc.type != Type.Unknown: # non-XBRL document is not in DTS
doc.inDTS = True # now known to be discovered
if doc.type == Type.SCHEMA: # schema coming newly into DTS
doc.schemaDiscoverChildElements(doc.xmlRootElement)
href = (element, doc, id if len(id) > 0 else None)
self.hrefObjects.append(href)
return href
return None
示例5: resolveUri
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def resolveUri(self, hrefObject=None, uri=None, dtsModelXbrl=None):
"""Returns the modelObject within modelDocment that resolves a URI based on arguments relative
to this element
:param hrefObject: an optional tuple of (hrefElement, modelDocument, id), or
:param uri: An (element scheme pointer), and dtsModelXbrl (both required together if for a multi-instance href)
:type uri: str
:param dtsModelXbrl: DTS of href resolution (default is the element's own modelXbrl)
:type dtsModelXbrl: ModelXbrl
:returns: ModelObject -- Document node corresponding to the href or resolved uri
"""
if dtsModelXbrl is None:
dtsModelXbrl = self.modelXbrl
doc = None
if hrefObject:
hrefElt,doc,id = hrefObject
elif uri:
from arelle import UrlUtil
url, id = UrlUtil.splitDecodeFragment(uri)
if url == "":
doc = self.modelDocument
else:
normalizedUrl = self.modelXbrl.modelManager.cntlr.webCache.normalizeUrl(
url,
self.modelDocument.baseForElement(self))
doc = dtsModelXbrl.urlDocs.get(normalizedUrl)
from arelle import ModelDocument
if isinstance(doc, ModelDocument.ModelDocument):
if id is None:
return doc
elif id in doc.idObjects:
return doc.idObjects[id]
else:
from arelle.XmlUtil import xpointerElement
xpointedElement = xpointerElement(doc,id)
# find element
for docModelObject in doc.xmlRootElement.iter():
if docModelObject == xpointedElement:
doc.idObjects[id] = docModelObject # cache for reuse
return docModelObject
return None
示例6: checkConcept
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def checkConcept(val, concept):
if concept.get("{http://xbrl.org/2005/xbrldt}typedDomainRef"):
if concept.isDimensionItem:
typedDomainElement = concept.typedDomainElement
if typedDomainElement is None:
url, id = UrlUtil.splitDecodeFragment(concept.get("{http://xbrl.org/2005/xbrldt}typedDomainRef"))
if len(id) == 0:
val.modelXbrl.error(
"xbrldte:TypedDimensionURIError",
_("Concept %(concept)s typedDomainRef has no fragment identifier"),
modelObject=concept,
concept=concept.qname,
)
else:
val.modelXbrl.error(
"xbrldte:OutOfDTSSchemaError",
_("Concept %(concept)s typedDomainRef is not resolved"),
modelObject=concept,
concept=concept.qname,
)
elif (
not isinstance(typedDomainElement, ModelConcept)
or not typedDomainElement.isGlobalDeclaration
or typedDomainElement.abstract == "true"
):
val.modelXbrl.error(
"xbrldte:TypedDimensionError",
_("Concept %(concept)s typedDomainRef must identify a non-abstract element"),
modelObject=concept,
concept=concept.qname,
)
else:
val.modelXbrl.error(
"xbrldte:TypedDomainRefError",
_("Concept %(concept)s is not a dimension item but has a typedDomainRef"),
modelObject=concept,
concept=concept.qname,
)
示例7: checkDTSdocument
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import splitDecodeFragment [as 别名]
def checkDTSdocument(val, modelDocument, isFilingDocument):
for hrefElt, _hrefedDoc, hrefId in modelDocument.hrefObjects:
if hrefId: #check scheme regardless of whether document loaded
# check all xpointer schemes
for scheme, _path in XmlUtil.xpointerSchemes(hrefId):
if scheme == "element" and val.validateDisclosureSystem:
val.modelXbrl.error(("EFM.6.03.06", "GFM.1.01.03"),
_("Href %(elementHref)s may only have shorthand xpointers"),
modelObject=hrefElt,
elementHref=hrefElt.get("{http://www.w3.org/1999/xlink}href"))
if not isFilingDocument:
return # not a filing's extension document
if modelDocument.type == ModelDocument.Type.SCHEMA:
if modelDocument.targetNamespace is not None and len(modelDocument.targetNamespace) > 85:
l = len(modelDocument.targetNamespace.encode("utf-8"))
if l > 255:
val.modelXbrl.error("EFM.6.07.30",
_("Schema targetNamespace length (%(length)s) is over 255 bytes long in utf-8 %(targetNamespace)s"),
modelObject=modelDocument.xmlRootElement, length=l, targetNamespace=modelDocument.targetNamespace, value=modelDocument.targetNamespace)
if modelDocument.type in (ModelDocument.Type.SCHEMA, ModelDocument.Type.LINKBASE):
isSchema = modelDocument.type == ModelDocument.Type.SCHEMA
if isSchema:
for elt in modelDocument.xmlRootElement.iter(tag="{http://www.w3.org/2001/XMLSchema}*"):
if elt.namespaceURI == XbrlConst.xsd:
localName = elt.localName
if localName in {"element", "complexType", "simpleType"}:
name = elt.get("name")
if name and len(name) > 64:
l = len(name.encode("utf-8"))
if l > 200:
val.modelXbrl.error("EFM.6.07.29",
_("Schema %(element)s has a name length (%(length)s) over 200 bytes long in utf-8, %(name)s."),
modelObject=elt, element=localName, name=name, length=l)
for elt in modelDocument.xmlRootElement.iter():
if isinstance(elt, ModelObject):
xlinkType = elt.get("{http://www.w3.org/1999/xlink}type")
xlinkRole = elt.get("{http://www.w3.org/1999/xlink}role")
if elt.namespaceURI == XbrlConst.link:
# check schema roleTypes
if elt.localName in ("roleType","arcroleType"):
uriAttr = {"roleType":"roleURI", "arcroleType":"arcroleURI"}[elt.localName]
roleURI = elt.get(uriAttr)
if len(roleURI) > 85:
l = len(roleURI.encode("utf-8"))
if l > 255:
val.modelXbrl.error("EFM.6.07.30",
_("Schema %(element)s %(attribute)s length (%(length)s) is over 255 bytes long in utf-8 %(roleURI)s"),
modelObject=elt, element=elt.qname, attribute=uriAttr, length=l, roleURI=roleURI, value=roleURI)
if elt.localName == "arcroleRef":
refUri = elt.get("arcroleURI")
hrefAttr = elt.get("{http://www.w3.org/1999/xlink}href")
hrefUri, hrefId = UrlUtil.splitDecodeFragment(hrefAttr)
if hrefUri not in val.disclosureSystem.standardTaxonomiesDict:
val.modelXbrl.error(("EFM.6.09.06", "GFM.1.04.06"),
_("Arcrole %(refURI)s arcroleRef %(xlinkHref)s must be a standard taxonomy"),
modelObject=elt, refURI=refUri, xlinkHref=hrefUri)
if modelDocument.type == ModelDocument.Type.INLINEXBRL and elt.namespaceURI in XbrlConst.ixbrlAll:
if elt.localName == "footnote":
if val.validateGFM:
if elt.get("{http://www.w3.org/1999/xlink}arcrole") != XbrlConst.factFootnote:
# must be in a nonDisplay div
if not any(inlineDisplayNonePattern.search(e.get("style") or "")
for e in XmlUtil.ancestors(elt, XbrlConst.xhtml, "div")):
val.modelXbrl.error(("EFM.N/A", "GFM:1.10.16"),
_("Inline XBRL footnote %(footnoteID)s must be in non-displayable div due to arcrole %(arcrole)s"),
modelObject=elt, footnoteID=elt.get("footnoteID"),
arcrole=elt.get("{http://www.w3.org/1999/xlink}arcrole"))
if not elt.get("{http://www.w3.org/XML/1998/namespace}lang"):
val.modelXbrl.error(("EFM.N/A", "GFM:1.10.13"),
_("Inline XBRL footnote %(footnoteID)s is missing an xml:lang attribute"),
modelObject=elt, footnoteID=id)
if xlinkType == "extended":
if not xlinkRole or xlinkRole == "":
val.modelXbrl.error(("EFM.6.09.04", "GFM.1.04.04"),
"%(element)s is missing an xlink:role",
modelObject=elt, element=elt.qname)
if not val.extendedElementName:
val.extendedElementName = elt.qname
elif val.extendedElementName != elt.qname:
val.modelXbrl.error(("EFM.6.09.07", "GFM:1.04.07"),
_("Extended element %(element)s must be the same as %(element2)s"),
modelObject=elt, element=elt.qname, element2=val.extendedElementName)
elif xlinkType == "resource":
if not xlinkRole:
val.modelXbrl.error(("EFM.6.09.04", "GFM.1.04.04"),
_("%(element)s is missing an xlink:role"),
modelObject=elt, element=elt.qname)
elif not XbrlConst.isStandardRole(xlinkRole):
modelsRole = val.modelXbrl.roleTypes.get(xlinkRole)
if (modelsRole is None or len(modelsRole) == 0 or
modelsRole[0].modelDocument.targetNamespace not in val.disclosureSystem.standardTaxonomiesDict):
val.modelXbrl.error(("EFM.6.09.05", "GFM.1.04.05"),
_("Resource %(xlinkLabel)s role %(role)s is not a standard taxonomy role"),
modelObject=elt, xlinkLabel=elt.get("{http://www.w3.org/1999/xlink}label"), role=xlinkRole, element=elt.qname,
#.........这里部分代码省略.........