本文整理汇总了Python中arelle.UrlUtil.authority方法的典型用法代码示例。如果您正苦于以下问题:Python UrlUtil.authority方法的具体用法?Python UrlUtil.authority怎么用?Python UrlUtil.authority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.UrlUtil
的用法示例。
在下文中一共展示了UrlUtil.authority方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadStandardTaxonomiesDict
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def loadStandardTaxonomiesDict(self):
if self.selection:
self.standardTaxonomiesDict = {}
self.standardLocalHrefs = set()
self.standardAuthorities = set()
if not self.standardTaxonomiesUrl:
return
basename = os.path.basename(self.standardTaxonomiesUrl)
self.modelManager.cntlr.showStatus(_("parsing {0}").format(basename))
try:
for file in (self.modelManager.cntlr.webCache.getfilename(self.standardTaxonomiesUrl),
os.path.join(self.modelManager.cntlr.configDir,"xbrlschemafiles.xml")):
xmldoc = etree.parse(file)
for locElt in xmldoc.iter(tag="Loc"):
href = None
localHref = None
namespaceUri = None
attType = None
family = None
for childElt in locElt.iterchildren():
ln = childElt.tag
value = childElt.text.strip()
if ln == "Href":
href = value
elif ln == "LocalHref":
localHref = value
elif ln == "Namespace":
namespaceUri = value
elif ln == "AttType":
attType = value
elif ln == "Family":
family = value
if href:
if namespaceUri and (attType == "SCH" or attType == "ENT"):
if namespaceUri not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[namespaceUri] = (href, localHref)
authority = UrlUtil.authority(namespaceUri)
self.standardAuthorities.add(authority)
if family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
if href not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[href] = "Allowed" + attType
if localHref:
self.standardLocalHrefs.add(localHref)
elif attType == "SCH" and family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
except (EnvironmentError,
etree.LxmlError) as err:
self.modelManager.cntlr.addToLog("{0}: import error: {1}".format(basename,err))
etree.clear_error_log()
示例2: loadStandardTaxonomiesDict
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def loadStandardTaxonomiesDict(self):
if self.selection:
self.standardTaxonomiesDict = {}
self.standardAuthorities = set()
if not self.standardTaxonomiesUrl:
return
basename = os.path.basename(self.standardTaxonomiesUrl)
self.modelManager.cntlr.showStatus(_("parsing {0}").format(basename))
try:
for file in (self.modelManager.cntlr.webCache.getfilename(self.standardTaxonomiesUrl),
os.path.join(self.modelManager.cntlr.configDir,"xbrlschemafiles.xml")):
xmldoc = xml.dom.minidom.parse(file)
for locElt in xmldoc.getElementsByTagName("Loc"):
href = None
localHref = None
namespaceUri = None
attType = None
family = None
for childElt in locElt.childNodes:
if childElt.nodeType == 1: #element
ln = childElt.localName
value = XmlUtil.innerText(childElt)
if ln == "Href":
href = value
elif ln == "LocalHref":
localHref = value
elif ln == "Namespace":
namespaceUri = value
elif ln == "AttType":
attType = value
elif ln == "Family":
family = value
if href:
if namespaceUri and (attType == "SCH" or attType == "ENT"):
if namespaceUri not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[namespaceUri] = (href, localHref)
authority = UrlUtil.authority(namespaceUri)
self.standardAuthorities.add(authority)
if family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
if href not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[href] = "Allowed" + attType
except (EnvironmentError,
xml.parsers.expat.ExpatError,
xml.dom.DOMException) as err:
self.modelManager.cntlr.addToLog("{0}: import error: {1}".format(basename,err))
示例3: uriAuthorityValid
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def uriAuthorityValid(self, uri):
return UrlUtil.authority(uri) in self.standardAuthorities
示例4: loadStandardTaxonomiesDict
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def loadStandardTaxonomiesDict(self):
if self.selection:
self.standardTaxonomiesDict = defaultdict(set)
self.familyHrefs = defaultdict(set)
self.standardLocalHrefs = defaultdict(set)
self.standardAuthorities = set()
self.standardPrefixes = {}
if not self.standardTaxonomiesUrl:
return
basename = os.path.basename(self.standardTaxonomiesUrl)
self.modelManager.cntlr.showStatus(_("parsing {0}").format(basename))
file = None
try:
from arelle.FileSource import openXmlFileStream
for filepath in (self.standardTaxonomiesUrl,
os.path.join(self.modelManager.cntlr.configDir,"xbrlschemafiles.xml")):
file = openXmlFileStream(self.modelManager.cntlr, filepath, stripDeclaration=True)[0]
xmldoc = etree.parse(file)
file.close()
for locElt in xmldoc.iter(tag="Loc"):
href = None
localHref = None
namespaceUri = None
prefix = None
attType = None
family = None
elements = None
version = None
for childElt in locElt.iterchildren():
ln = childElt.tag
value = childElt.text.strip()
if ln == "Href":
href = value
elif ln == "LocalHref":
localHref = value
elif ln == "Namespace":
namespaceUri = value
elif ln == "Prefix":
prefix = value
elif ln == "AttType":
attType = value
elif ln == "Family":
family = value
elif ln == "Elements":
elements = value
elif ln == "Version":
version = value
if href:
if namespaceUri and (attType == "SCH" or attType == "ENT"):
self.standardTaxonomiesDict[namespaceUri].add(href)
if localHref:
self.standardLocalHrefs[namespaceUri].add(localHref)
authority = UrlUtil.authority(namespaceUri)
self.standardAuthorities.add(authority)
if family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
if prefix:
self.standardPrefixes[namespaceUri] = prefix
if href not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[href] = "Allowed" + attType
if family:
self.familyHrefs[family].add(ErxlLoc(family, version, href, attType, elements, namespaceUri))
elif attType == "SCH" and family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
except (EnvironmentError,
etree.LxmlError) as err:
self.modelManager.cntlr.addToLog("{0}: import error: {1}".format(basename,err))
etree.clear_error_log()
if file:
file.close()
示例5: checkDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkDTS(val, modelDocument, visited):
global targetNamespaceDatePattern, efmFilenamePattern, roleTypePattern, arcroleTypePattern, \
arcroleDefinitionPattern, namePattern, linkroleDefinitionBalanceIncomeSheet, \
namespacesConflictPattern
if targetNamespaceDatePattern is None:
targetNamespaceDatePattern = re.compile(r"/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|"
r"/([12][0-9]{3})([01][0-9])([0-3][0-9])|")
efmFilenamePattern = re.compile(r"^[a-z0-9][a-z0-9_\.\-]*(\.xsd|\.xml)$")
roleTypePattern = re.compile(r"^.*/role/[^/\s]+$")
arcroleTypePattern = re.compile(r"^.*/arcrole/[^/\s]+$")
arcroleDefinitionPattern = re.compile(r"^.*[^\\s]+.*$") # at least one non-whitespace character
namePattern = re.compile("[][()*+?\\\\/^{}|@#%^=~`\"';:,<>&$\u00a3\u20ac]") # u20ac=Euro, u00a3=pound sterling
linkroleDefinitionBalanceIncomeSheet = re.compile(r"[^-]+-\s+Statement\s+-\s+.*(income|balance|financial\W+position)",
re.IGNORECASE)
namespacesConflictPattern = re.compile(r"http://(xbrl\.us|fasb\.org|xbrl\.sec\.gov)/(dei|us-types|us-roles|rr)/([0-9]{4}-[0-9]{2}-[0-9]{2})$")
nonDomainItemNameProblemPattern = re.compile(
r"({0})|(FirstQuarter|SecondQuarter|ThirdQuarter|FourthQuarter|[1-4]Qtr|Qtr[1-4]|ytd|YTD|HalfYear)(?:$|[A-Z\W])"
.format(re.sub(r"\W", "", (val.entityRegistrantName or "").title())))
visited.append(modelDocument)
definesLabelLinkbase = False
for referencedDocument in modelDocument.referencesDocument.items():
#6.07.01 no includes
if referencedDocument[1] == "include":
val.modelXbrl.error(("EFM.6.07.01", "GFM.1.03.01", "SBR.NL.2.2.0.18"),
_("Taxonomy schema %(schema)s includes %(include)s, only import is allowed"),
modelObject=modelDocument,
schema=os.path.basename(modelDocument.uri),
include=os.path.basename(referencedDocument[0].uri))
if referencedDocument[0] not in visited:
checkDTS(val, referencedDocument[0], visited)
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if val.validateEFM:
if modelDocument.uri in val.disclosureSystem.standardTaxonomiesDict:
if modelDocument.targetNamespace:
# check for duplicates of us-types, dei, and rr taxonomies
match = namespacesConflictPattern.match(modelDocument.targetNamespace)
if match is not None:
val.standardNamespaceConflicts[match.group(2)].add(modelDocument)
else:
if len(modelDocument.basename) > 32:
val.modelXbrl.error("EFM.5.01.01.tooManyCharacters",
_("Document file name %(filename)s must not exceed 32 characters."),
modelObject=modelDocument, filename=modelDocument.basename)
if not efmFilenamePattern.match(modelDocument.basename):
val.modelXbrl.error("EFM.5.01.01",
_("Document file name %(filename)s must start with a-z or 0-9, contain lower case letters, ., -, _, and end with .xsd or .xml."),
modelObject=modelDocument, filename=modelDocument.basename)
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
# check schema contents types
if val.validateSBRNL:
definesLinkroles = False
definesArcroles = False
definesLinkParts = False
definesAbstractItems = False
definesNonabstractItems = False
definesConcepts = False
definesTuples = False
definesPresentationTuples = False
definesSpecificationTuples = False
definesTypes = False
definesEnumerations = False
definesDimensions = False
definesDomains = False
definesHypercubes = False
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(("EFM.6.07.03", "GFM.1.03.03"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s is a disallowed authority"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace, targetNamespaceAuthority=targetNamespaceAuthority)
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None or not modelDocument.targetNamespace.startswith("http://"):
match = None
elif val.validateEFMorGFM:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = targetNamespaceDatePattern.match(targetNamespaceDate)
else:
match = None
if match is not None:
try:
if match.lastindex == 3:
date = datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
date = datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
except ValueError:
match = None
if match is None:
#.........这里部分代码省略.........
示例6: uriAuthorityValid
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def uriAuthorityValid(self, uri):
if self.standardTaxonomiesUrl:
return UrlUtil.authority(uri) in self.standardAuthorities
return True # no standard authorities to test
示例7: loadStandardTaxonomiesDict
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def loadStandardTaxonomiesDict(self):
if self.selection:
self.standardTaxonomiesDict = defaultdict(set)
self.familyHrefs = defaultdict(set)
self.standardLocalHrefs = defaultdict(set)
self.standardAuthorities = set()
self.standardPrefixes = {}
if not self.standardTaxonomiesUrl:
return
basename = os.path.basename(self.standardTaxonomiesUrl)
self.modelManager.cntlr.showStatus(_("parsing {0}").format(basename))
try:
from arelle.FileSource import openXmlFileStream
for filepath in (self.standardTaxonomiesUrl,
os.path.join(self.modelManager.cntlr.configDir,"xbrlschemafiles.xml")):
xmldoc = etree.parse(filepath) # must open with file path for xinclude to know base of file
xmldoc.xinclude() # to include elements below root use xpointer(/*/*)
for erxlElt in xmldoc.iter(tag="Erxl"):
v = erxlElt.get("version")
if v and re.match(r"[0-9]+([.][0-9]+)*$", v):
vSplit = v.split('.') # at least 3 digits always!
self.version = tuple(int(n) for n in vSplit) + tuple(0 for n in range(3 - len(vSplit)))
break
for locElt in xmldoc.iter(tag="Loc"):
href = None
localHref = None
namespaceUri = None
prefix = None
attType = None
family = None
elements = None
version = None
for childElt in locElt.iterchildren():
ln = childElt.tag
value = childElt.text.strip()
if ln == "Href":
href = value
elif ln == "LocalHref":
localHref = value
elif ln == "Namespace":
namespaceUri = value
elif ln == "Prefix":
prefix = value
elif ln == "AttType":
attType = value
elif ln == "Family":
family = value
elif ln == "Elements":
elements = value
elif ln == "Version":
version = value
if href:
if namespaceUri and (attType == "SCH" or attType == "ENT"):
self.standardTaxonomiesDict[namespaceUri].add(href)
if localHref:
self.standardLocalHrefs[namespaceUri].add(localHref)
authority = UrlUtil.authority(namespaceUri)
self.standardAuthorities.add(authority)
if family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
if prefix:
self.standardPrefixes[namespaceUri] = prefix
if href not in self.standardTaxonomiesDict:
self.standardTaxonomiesDict[href] = "Allowed" + attType
if family:
self.familyHrefs[family].add(ErxlLoc(family, version, href, attType, elements, namespaceUri))
elif attType == "SCH" and family == "BASE":
self.baseTaxonomyNamespaces.add(namespaceUri)
except (EnvironmentError,
etree.LxmlError) as err:
self.modelManager.cntlr.addToLog(_("Disclosure System \"%(name)s\" import %(importFile)s, error: %(error)s"),
messageCode="arelle:disclosureSystemImportError",
messageArgs={"error": str(err), "name": self.name, "importFile": basename},
level=logging.ERROR)
etree.clear_error_log()
示例8: checkFilingDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkFilingDTS(val, modelDocument, isEFM, isGFM, visited):
global targetNamespaceDatePattern, efmFilenamePattern, htmlFileNamePattern, roleTypePattern, arcroleTypePattern, \
arcroleDefinitionPattern, namePattern, linkroleDefinitionBalanceIncomeSheet, \
usNamespacesConflictPattern, ifrsNamespacesConflictPattern
if targetNamespaceDatePattern is None:
targetNamespaceDatePattern = re.compile(r"/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|"
r"/([12][0-9]{3})([01][0-9])([0-3][0-9])|")
efmFilenamePattern = re.compile(r"^[a-z0-9][a-zA-Z0-9_\.\-]*(\.xsd|\.xml|\.htm)$")
htmlFileNamePattern = re.compile(r"^[a-zA-Z0-9][._a-zA-Z0-9-]*(\.htm)$")
roleTypePattern = re.compile(r"^.*/role/[^/\s]+$")
arcroleTypePattern = re.compile(r"^.*/arcrole/[^/\s]+$")
arcroleDefinitionPattern = re.compile(r"^.*[^\\s]+.*$") # at least one non-whitespace character
namePattern = re.compile("[][()*+?\\\\/^{}|@#%^=~`\"';:,<>&$\u00a3\u20ac]") # u20ac=Euro, u00a3=pound sterling
linkroleDefinitionBalanceIncomeSheet = re.compile(r"[^-]+-\s+Statement\s+-\s+.*(income|balance|financial\W+position)",
re.IGNORECASE)
usNamespacesConflictPattern = re.compile(r"http://(xbrl\.us|fasb\.org|xbrl\.sec\.gov)/(dei|us-types|us-roles|rr)/([0-9]{4}-[0-9]{2}-[0-9]{2})$")
ifrsNamespacesConflictPattern = re.compile(r"http://xbrl.ifrs.org/taxonomy/([0-9]{4}-[0-9]{2}-[0-9]{2})/(ifrs[\w-]*)$")
nonDomainItemNameProblemPattern = re.compile(
r"({0})|(FirstQuarter|SecondQuarter|ThirdQuarter|FourthQuarter|[1-4]Qtr|Qtr[1-4]|ytd|YTD|HalfYear)(?:$|[A-Z\W])"
.format(re.sub(r"\W", "", (val.entityRegistrantName or "").title())))
visited.append(modelDocument)
for referencedDocument, modelDocumentReference in modelDocument.referencesDocument.items():
#6.07.01 no includes
if modelDocumentReference.referenceType == "include":
val.modelXbrl.error(("EFM.6.07.01", "GFM.1.03.01"),
_("Taxonomy schema %(schema)s includes %(include)s, only import is allowed"),
modelObject=modelDocumentReference.referringModelObject,
schema=os.path.basename(modelDocument.uri),
include=os.path.basename(referencedDocument.uri))
if referencedDocument not in visited and referencedDocument.inDTS: # ignore EdgarRenderer added non-DTS documents
checkFilingDTS(val, referencedDocument, isEFM, isGFM, visited)
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if isEFM:
if modelDocument.uri in val.disclosureSystem.standardTaxonomiesDict:
if modelDocument.targetNamespace:
# check for duplicates of us-types, dei, and rr taxonomies
for pattern, indexGroup in ((usNamespacesConflictPattern,2),(ifrsNamespacesConflictPattern,2)):
match = pattern.match(modelDocument.targetNamespace)
if match is not None:
val.standardNamespaceConflicts[match.group(indexGroup)].add(modelDocument)
else:
if len(modelDocument.basename) > 32:
val.modelXbrl.error("EFM.5.01.01.tooManyCharacters",
_("Document file name %(filename)s must not exceed 32 characters."),
modelObject=modelDocument, filename=modelDocument.basename)
if modelDocument.type == ModelDocument.Type.INLINEXBRL:
if not htmlFileNamePattern.match(modelDocument.basename):
val.modelXbrl.error("EFM.5.01.01",
_("Document file name %(filename)s must start with a-z or 0-9, contain upper or lower case letters, ., -, _, and end with .htm."),
modelObject=modelDocument, filename=modelDocument.basename)
elif not efmFilenamePattern.match(modelDocument.basename):
val.modelXbrl.error("EFM.5.01.01",
_("Document file name %(filename)s must start with a-z or 0-9, contain upper or lower case letters, ., -, _, and end with .xsd or .xml."),
modelObject=modelDocument, filename=modelDocument.basename)
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
val.hasExtensionSchema = True
# check schema contents types
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(("EFM.6.07.03", "GFM.1.03.03"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s is a disallowed authority"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace,
targetNamespaceAuthority=UrlUtil.authority(modelDocument.targetNamespace, includeScheme=False))
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None or not modelDocument.targetNamespace.startswith("http://"):
match = None
else:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = targetNamespaceDatePattern.match(targetNamespaceDate)
if match is not None:
try:
if match.lastindex == 3:
date = datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
date = datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
except ValueError:
match = None
if match is None:
val.modelXbrl.error(("EFM.6.07.04", "GFM.1.03.04"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s must have format http://{authority}/{versionDate}"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace)
elif val.fileNameDate and date > val.fileNameDate:
val.modelXbrl.info(("EFM.6.07.06", "GFM.1.03.06"),
_("Warning: Taxonomy schema %(schema)s namespace %(targetNamespace)s has date later than document name date %(docNameDate)s"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace,
docNameDate=val.fileNameDate)
#.........这里部分代码省略.........
示例9: checkFilingDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkFilingDTS(val, modelDocument, isEFM, isGFM, visited):
global targetNamespaceDatePattern, efmFilenamePattern, htmlFileNamePattern, roleTypePattern, arcroleTypePattern, \
arcroleDefinitionPattern, namePattern, linkroleDefinitionBalanceIncomeSheet
if targetNamespaceDatePattern is None:
targetNamespaceDatePattern = re.compile(r"/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|"
r"/([12][0-9]{3})([01][0-9])([0-3][0-9])|")
efmFilenamePattern = re.compile(r"^[a-z0-9][a-zA-Z0-9_\.\-]*(\.xsd|\.xml|\.htm)$")
htmlFileNamePattern = re.compile(r"^[a-zA-Z0-9][._a-zA-Z0-9-]*(\.htm)$")
roleTypePattern = re.compile(r"^.*/role/[^/\s]+$")
arcroleTypePattern = re.compile(r"^.*/arcrole/[^/\s]+$")
arcroleDefinitionPattern = re.compile(r"^.*[^\\s]+.*$") # at least one non-whitespace character
namePattern = re.compile("[][()*+?\\\\/^{}|@#%^=~`\"';:,<>&$\u00a3\u20ac]") # u20ac=Euro, u00a3=pound sterling
linkroleDefinitionBalanceIncomeSheet = re.compile(r"[^-]+-\s+Statement\s+-\s+.*(income|balance|financial\W+position)",
re.IGNORECASE)
nonDomainItemNameProblemPattern = re.compile(
r"({0})|(FirstQuarter|SecondQuarter|ThirdQuarter|FourthQuarter|[1-4]Qtr|Qtr[1-4]|ytd|YTD|HalfYear)(?:$|[A-Z\W])"
.format(re.sub(r"\W", "", (val.entityRegistrantName or "").title())))
visited.append(modelDocument)
for referencedDocument, modelDocumentReference in modelDocument.referencesDocument.items():
#6.07.01 no includes
if modelDocumentReference.referenceType == "include":
val.modelXbrl.error(("EFM.6.07.01", "GFM.1.03.01"),
_("Taxonomy schema %(schema)s includes %(include)s, only import is allowed"),
modelObject=modelDocumentReference.referringModelObject,
schema=modelDocument.basename,
include=referencedDocument.basename)
if referencedDocument not in visited and (referencedDocument.inDTS or referencedDocument.type == ModelDocument.Type.INLINEXBRLDOCUMENTSET): # ignore EdgarRenderer added non-DTS documents
checkFilingDTS(val, referencedDocument, isEFM, isGFM, visited)
if modelDocument.type == ModelDocument.Type.INLINEXBRLDOCUMENTSET:
return # nothing to check in inline document set surrogate parent
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if isEFM:
if modelDocument.uri in val.disclosureSystem.standardTaxonomiesDict:
if modelDocument.targetNamespace:
# check for duplicates of us-types, dei, and rr taxonomies
match = standardNamespacesPattern.match(modelDocument.targetNamespace)
if match is not None:
conflictClass = match.group(2) or match.group(5)
if (conflictClass == 'us-gaap' and match.group(3) < '2018') or conflictClass == 'srt':
val.standardNamespaceConflicts['srt+us-gaap'].add(modelDocument) # ignore non-srt multi-usgaap in Filing.py
if conflictClass == 'us-gaap' or conflictClass == 'ifrs-full':
val.standardNamespaceConflicts['ifrs+us-gaap'].add(modelDocument)
if conflictClass not in ('us-gaap', 'srt'):
val.standardNamespaceConflicts[conflictClass].add(modelDocument)
else:
if len(modelDocument.basename) > 32:
val.modelXbrl.error("EFM.5.01.01.tooManyCharacters",
_("Document file name %(filename)s must not exceed 32 characters."),
edgarCode="cp-0501-File-Name-Length",
modelObject=modelDocument, filename=modelDocument.basename)
if modelDocument.type != ModelDocument.Type.INLINEXBRLDOCUMENTSET:
if modelDocument.type == ModelDocument.Type.INLINEXBRL:
_pattern = htmlFileNamePattern
_suffix = ".htm"
else:
_pattern = efmFilenamePattern
_suffix = ".xsd or .xml"
if not _pattern.match(modelDocument.basename):
val.modelXbrl.error("EFM.5.01.01",
_("Document file name %(filename)s must start with a-z or 0-9, contain upper or lower case letters, ., -, _, and end with %(suffix)s."),
edgarCode="cp-0501-File-Name",
modelObject=modelDocument, filename=modelDocument.basename, suffix=_suffix)
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
val.hasExtensionSchema = True
# check schema contents types
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(("EFM.6.07.03", "GFM.1.03.03"),
_("The target namespace, %(targetNamespace)s cannot have the same authority (%(targetNamespaceAuthority)s) as a standard "
"taxonomy, in %(schema)s. Please change your target namespace."),
edgarCode="fs-0703-Extension-Has-Standard-Namespace-Authority",
modelObject=modelDocument, schema=modelDocument.basename, targetNamespace=modelDocument.targetNamespace,
targetNamespaceAuthority=UrlUtil.authority(modelDocument.targetNamespace, includeScheme=False))
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None or not modelDocument.targetNamespace.startswith("http://"):
match = None
else:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = targetNamespaceDatePattern.match(targetNamespaceDate)
if match is not None:
try:
if match.lastindex == 3:
date = datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
date = datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
#.........这里部分代码省略.........
示例10: checkDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkDTS(val, modelDocument, visited):
visited.append(modelDocument)
definesLabelLinkbase = False
for referencedDocument in modelDocument.referencesDocument.items():
#6.07.01 no includes
if referencedDocument[1] == "include":
val.modelXbrl.error(
_("Taxonomy schema {0} includes {1}, only import is allowed").format(
os.path.basename(modelDocument.uri),
os.path.basename(referencedDocument[0].uri)),
"err", "EFM.6.07.01", "GFM.1.03.01", "SBR.NL.2.2.0.18")
if referencedDocument[0] not in visited:
checkDTS(val, referencedDocument[0], visited)
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
# check schema contents types
if val.validateSBRNL:
definesConcepts = False
definesLinkroles = False
definesArcroles = False
definesLinkParts = False
definesAbstractItems = False
definesNonabstractItems = False
definesTuples = False
definesEnumerations = False
definesDimensions = False
definesDomains = False
definesHypercubes = False
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(
_("Taxonomy schema {0} namespace {1} is a disallowed authority").format(
os.path.basename(modelDocument.uri),
modelDocument.targetNamespace),
"err", "EFM.6.07.03", "GFM.1.03.03")
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None:
match = None
elif val.validateEFMorGFM:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = val.targetNamespaceDatePattern.match(targetNamespaceDate)
else:
match = None
if match is not None:
try:
if match.lastindex == 3:
datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
except ValueError:
match = None
if match is None:
val.modelXbrl.error(
_("Taxonomy schema {0} namespace {1} must have format http://{2}authority{3}/{2}versionDate{3}").format(
os.path.basename(modelDocument.uri),
modelDocument.targetNamespace, "{", "}"),
"err", "EFM.6.07.04", "GFM.1.03.04")
if modelDocument.targetNamespace is not None:
# 6.7.5 check prefix for _
prefix = XmlUtil.xmlnsprefix(modelDocument.xmlRootElement,modelDocument.targetNamespace)
if prefix and "_" in prefix:
val.modelXbrl.error(
_("Taxonomy schema {0} namespace {1} prefix {2} must not have an '_'").format(
os.path.basename(modelDocument.uri),
modelDocument.targetNamespace,
prefix),
"err", "EFM.6.07.07", "GFM.1.03.07")
for eltName in modelDocument.xmlRootElement.getElementsByTagNameNS(XbrlConst.xsd, "element"):
# 6.7.16 name not duplicated in standard taxonomies
name = eltName.getAttribute("name")
concepts = val.modelXbrl.nameConcepts.get(name)
modelConcept = None
if concepts is not None:
for c in concepts:
if c.modelDocument == modelDocument:
modelConcept = c
elif (val.validateEFMorGFM and
not c.modelDocument.uri.startswith(val.modelXbrl.uriDir)):
val.modelXbrl.error(
_("Taxonomy schema {0} element {1} is also defined in standard taxonomy schema {2}").format(
os.path.basename(modelDocument.uri),
name,
os.path.basename(c.modelDocument.uri)),
"err", "EFM.6.07.16", "GFM.1.03.18")
if val.validateSBRNL:
for c in concepts:
if c.modelDocument != modelDocument:
relSet = val.modelXbrl.relationshipSet(XbrlConst.generalSpecial)
#.........这里部分代码省略.........
示例11: checkDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkDTS(val, modelDocument, visited):
global targetNamespaceDatePattern, roleTypePattern, arcroleTypePattern, arcroleDefinitionPattern
if targetNamespaceDatePattern is None:
targetNamespaceDatePattern = re.compile(r"/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|"
r"/([12][0-9]{3})([01][0-9])([0-3][0-9])|")
roleTypePattern = re.compile(r".*/role/[^/]+")
arcroleTypePattern = re.compile(r".*/arcrole/[^/]+")
arcroleDefinitionPattern = re.compile(r"^.*[^\\s]+.*$") # at least one non-whitespace character
visited.append(modelDocument)
definesLabelLinkbase = False
for referencedDocument in modelDocument.referencesDocument.items():
#6.07.01 no includes
if referencedDocument[1] == "include":
val.modelXbrl.error(("EFM.6.07.01", "GFM.1.03.01", "SBR.NL.2.2.0.18"),
_("Taxonomy schema %(schema)s includes %(include)s, only import is allowed"),
modelObject=modelDocument,
schema=os.path.basename(modelDocument.uri),
include=os.path.basename(referencedDocument[0].uri))
if referencedDocument[0] not in visited:
checkDTS(val, referencedDocument[0], visited)
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
# check schema contents types
if val.validateSBRNL:
definesLinkroles = False
definesArcroles = False
definesLinkParts = False
definesAbstractItems = False
definesNonabstractItems = False
definesConcepts = False
definesTuples = False
definesPresentationTuples = False
definesSpecificationTuples = False
definesTypes = False
definesEnumerations = False
definesDimensions = False
definesDomains = False
definesHypercubes = False
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(("EFM.6.07.03", "GFM.1.03.03"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s is a disallowed authority"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace)
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None:
match = None
elif val.validateEFMorGFM:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = targetNamespaceDatePattern.match(targetNamespaceDate)
else:
match = None
if match is not None:
try:
if match.lastindex == 3:
datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
except ValueError:
match = None
if match is None:
val.modelXbrl.error(("EFM.6.07.04", "GFM.1.03.04"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s must have format http://{authority}/{versionDate}"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace)
if modelDocument.targetNamespace is not None:
# 6.7.5 check prefix for _
prefix = XmlUtil.xmlnsprefix(modelDocument.xmlRootElement,modelDocument.targetNamespace)
if prefix and "_" in prefix:
val.modelXbrl.error(("EFM.6.07.07", "GFM.1.03.07"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s prefix %(prefix)s must not have an '_'"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace, prefix=prefix)
if val.validateSBRNL:
genrlSpeclRelSet = val.modelXbrl.relationshipSet(XbrlConst.generalSpecial)
for modelConcept in modelDocument.xmlRootElement.iterdescendants(tag="{http://www.w3.org/2001/XMLSchema}element"):
if isinstance(modelConcept,ModelConcept):
# 6.7.16 name not duplicated in standard taxonomies
name = modelConcept.get("name")
if name is None:
name = ""
if modelConcept.get("ref") is not None:
continue # don't validate ref's here
for c in val.modelXbrl.nameConcepts.get(name, []):
if c.modelDocument != modelDocument:
if (val.validateEFMorGFM and
not c.modelDocument.uri.startswith(val.modelXbrl.uriDir)):
val.modelXbrl.error(("EFM.6.07.16", "GFM.1.03.18"),
_("Concept %(concept)s is also defined in standard taxonomy schema schema %(standardSchema)s"),
modelObject=c, concept=modelConcept.qname, standardSchema=os.path.basename(c.modelDocument.uri))
#.........这里部分代码省略.........
示例12: checkDTS
# 需要导入模块: from arelle import UrlUtil [as 别名]
# 或者: from arelle.UrlUtil import authority [as 别名]
def checkDTS(val, modelDocument, visited):
global targetNamespaceDatePattern, roleTypePattern, arcroleTypePattern, arcroleDefinitionPattern
if targetNamespaceDatePattern is None:
targetNamespaceDatePattern = re.compile(r"/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|"
r"/([12][0-9]{3})([01][0-9])([0-3][0-9])|")
roleTypePattern = re.compile(r".*/role/[^/]+")
arcroleTypePattern = re.compile(r".*/arcrole/[^/]+")
arcroleDefinitionPattern = re.compile(r"^.*[^\\s]+.*$") # at least one non-whitespace character
visited.append(modelDocument)
definesLabelLinkbase = False
for referencedDocument in modelDocument.referencesDocument.items():
#6.07.01 no includes
if referencedDocument[1] == "include":
val.modelXbrl.error(("EFM.6.07.01", "GFM.1.03.01", "SBR.NL.2.2.0.18"),
_("Taxonomy schema %(schema)s includes %(include)s, only import is allowed"),
modelObject=modelDocument,
schema=os.path.basename(modelDocument.uri),
include=os.path.basename(referencedDocument[0].uri))
if referencedDocument[0] not in visited:
checkDTS(val, referencedDocument[0], visited)
if val.disclosureSystem.standardTaxonomiesDict is None:
pass
if (modelDocument.type == ModelDocument.Type.SCHEMA and
modelDocument.targetNamespace not in val.disclosureSystem.baseTaxonomyNamespaces and
modelDocument.uri.startswith(val.modelXbrl.uriDir)):
# check schema contents types
if val.validateSBRNL:
definesConcepts = False
definesLinkroles = False
definesArcroles = False
definesLinkParts = False
definesAbstractItems = False
definesNonabstractItems = False
definesTuples = False
definesEnumerations = False
definesDimensions = False
definesDomains = False
definesHypercubes = False
# 6.7.3 check namespace for standard authority
targetNamespaceAuthority = UrlUtil.authority(modelDocument.targetNamespace)
if targetNamespaceAuthority in val.disclosureSystem.standardAuthorities:
val.modelXbrl.error(("EFM.6.07.03", "GFM.1.03.03"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s is a disallowed authority"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace)
# 6.7.4 check namespace format
if modelDocument.targetNamespace is None:
match = None
elif val.validateEFMorGFM:
targetNamespaceDate = modelDocument.targetNamespace[len(targetNamespaceAuthority):]
match = targetNamespaceDatePattern.match(targetNamespaceDate)
else:
match = None
if match is not None:
try:
if match.lastindex == 3:
datetime.date(int(match.group(1)),int(match.group(2)),int(match.group(3)))
elif match.lastindex == 6:
datetime.date(int(match.group(4)),int(match.group(5)),int(match.group(6)))
else:
match = None
except ValueError:
match = None
if match is None:
val.modelXbrl.error(("EFM.6.07.04", "GFM.1.03.04"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s must have format http://{authority}/{versionDate}"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace)
if modelDocument.targetNamespace is not None:
# 6.7.5 check prefix for _
prefix = XmlUtil.xmlnsprefix(modelDocument.xmlRootElement,modelDocument.targetNamespace)
if prefix and "_" in prefix:
val.modelXbrl.error(("EFM.6.07.07", "GFM.1.03.07"),
_("Taxonomy schema %(schema)s namespace %(targetNamespace)s prefix %(prefix)s must not have an '_'"),
modelObject=modelDocument, schema=os.path.basename(modelDocument.uri), targetNamespace=modelDocument.targetNamespace, prefix=prefix)
for modelConcept in modelDocument.xmlRootElement.iterdescendants(tag="{http://www.w3.org/2001/XMLSchema}element"):
if isinstance(modelConcept,ModelConcept):
# 6.7.16 name not duplicated in standard taxonomies
name = modelConcept.get("name")
if name is None:
name = ""
if modelConcept.get("ref") is not None:
continue # don't validate ref's here
concepts = val.modelXbrl.nameConcepts.get(name)
if concepts is not None:
for c in concepts:
if c.modelDocument != modelDocument:
if (val.validateEFMorGFM and
not c.modelDocument.uri.startswith(val.modelXbrl.uriDir)):
val.modelXbrl.error(("EFM.6.07.16", "GFM.1.03.18"),
_("Concept %(concept)s is also defined in standard taxonomy schema schema %(standardSchema)s"),
modelObject=c, concept=modelConcept.qname, standardSchema=os.path.basename(c.modelDocument.uri))
elif val.validateSBRNL and c.modelDocument != modelDocument:
relSet = val.modelXbrl.relationshipSet(XbrlConst.generalSpecial)
if not (relSet.isRelated(modelConcept, "child", c) or relSet.isRelated(modelConcept, "child", c)):
#.........这里部分代码省略.........