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


Python arelle.XbrlConst类代码示例

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


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

示例1: ebaDecimals

def ebaDecimals(locale, value, concept, defaultDecimals):
    '''
    :type locale: dict
    :type value: string
    :type concept: ModelConcept
    :type defaultDecimals: str
    :rtype (boolean, str)
    '''
    isPercent = concept.typeQname == qnPercentItemType
    isInteger = XbrlConst.isIntegerXsdType(concept.type.baseXsdType)
    isMonetary = concept.isMonetary
    decimalsFound, decimals = decimalsComputer(locale, value, concept, defaultDecimals)
    if not(decimalsFound) or decimals == 'INF':
        return (decimalsFound, decimals)
    else:
        # the default values are for non-monetary items
        lowerBound = -20
        upperBound = 20
        decimalsAsInteger = int(decimals)
        if isMonetary:
            lowerBound = -3
        elif isInteger:
            lowerBound = upperBound = 0
        elif isPercent: # percent values
            lowerBound = 4
            upperBound = 20
        if decimalsAsInteger<lowerBound:
            decimals = str(lowerBound)
            decimalsAsInteger = lowerBound
        if decimalsAsInteger>upperBound:
            decimals = 'INF' # approximation
            decimalsAsInteger = upperBound
        return (decimalsFound, decimals)
开发者ID:acsone,项目名称:Arelle,代码行数:33,代码来源:ebaDecimalsFromAmounts.py

示例2: __init__

 def __init__(self, modelXbrl, tabWin, arcrole, linkrole=None, linkqname=None, arcqname=None, lang=None, treeColHdr=None):
     super().__init__(modelXbrl, tabWin, XbrlConst.baseSetArcroleLabel(arcrole)[1:], True, lang)
     self.arcrole = arcrole
     self.linkrole = linkrole
     self.linkqname = linkqname
     self.arcqname = arcqname
     self.treeColHdr = treeColHdr
开发者ID:marado,项目名称:Arelle,代码行数:7,代码来源:ViewWinRelationshipSet.py

示例3: insertResources

 def insertResources(self):
     self.showStatus("insert resources")
     table = self.getTable('resource', 'resource_id', 
                           ('role_uri_id', 'qname_id', 'document_id', 'document_line_number', 'document_column_number'), 
                           ('role_uri_id', 'qname_id', 'document_id', 'document_line_number', 'document_column_number'), 
                           tuple((self.uriId[resource.role],
                                  self.qnameId[resource.qname],
                                  self.documentIds[resource.modelDocument.uri],
                                  resource.sourceline,
                                  0)
                                 for arcrole in (XbrlConst.conceptLabel, XbrlConst.conceptReference)
                                 for rel in self.modelXbrl.relationshipSet(arcrole).modelRelationships
                                 for resource in (rel.fromModelObject, rel.toModelObject)
                                 if isinstance(resource, ModelResource)))
     self.resourceId = dict(((roleId, qnId, docId, line, offset), id)
                            for id, roleId, qnId, docId, line, offset in table)
     
     self.showStatus("insert labels")
     table = self.getTable('label_resource', 'resource_id', 
                           ('resource_id', 'label', 'xml_lang'), 
                           ('resource_id',), 
                           tuple((self.resourceId[self.uriId[resource.role],
                                                  self.qnameId[resource.qname],
                                                  self.documentIds[resource.modelDocument.uri],
                                                  resource.sourceline,
                                                  0],
                                  resource.elementText,
                                  resource.xmlLang)
                                 for arcrole in (XbrlConst.conceptLabel, XbrlConst.conceptReference)
                                 for rel in self.modelXbrl.relationshipSet(arcrole).modelRelationships
                                 for resource in (rel.fromModelObject, rel.toModelObject)
                                 if isinstance(resource, ModelResource) and XbrlConst.isLabelRole(resource.role)))
开发者ID:dknochen,项目名称:Arelle,代码行数:32,代码来源:XbrlPublicPostgresDB.py

示例4: __init__

 def __init__(
     self,
     modelXbrl,
     tabWin,
     arcrole,
     linkrole=None,
     linkqname=None,
     arcqname=None,
     lang=None,
     treeColHdr=None,
     showLinkroles=True,
     showRelationships=True,
     showColumns=True,
     expandAll=False,
     hasTableIndex=False,
 ):
     if isinstance(arcrole, (list, tuple)):
         tabName = arcrole[0]
     else:
         tabName = XbrlConst.baseSetArcroleLabel(arcrole)[1:]
     super(ViewRelationshipSet, self).__init__(modelXbrl, tabWin, tabName, True, lang)
     self.arcrole = arcrole
     self.linkrole = linkrole
     self.linkqname = linkqname
     self.arcqname = arcqname
     self.treeColHdr = treeColHdr
     self.showLinkroles = showLinkroles
     self.showRelationships = showRelationships
     self.showColumns = showColumns
     self.expandAllOnFirstDisplay = expandAll
     self.hasTableIndex = hasTableIndex
     self.isResourceArcrole = False
开发者ID:camirisk,项目名称:Arelle,代码行数:32,代码来源:ViewWinRelationshipSet.py

示例5: labelroles

def labelroles(modelXbrl, includeConceptName=False):
    # returns sorted list of tuples of arcrole basename and uri
    return sorted(
        set(
            (XbrlConst.labelroleLabel(r), r)
            for r in (modelXbrl.labelroles | ({XbrlConst.conceptNameLabelRole} if includeConceptName else set()))
        )
    )
开发者ID:8maki,项目名称:Arelle,代码行数:8,代码来源:ModelRelationshipSet.py

示例6: __init__

 def __init__(self, modelXbrl, tabWin, arcrole, linkrole=None, linkqname=None, arcqname=None, lang=None, treeColHdr=None):
     if isinstance(arcrole, (list,tuple)):
         tabName = arcrole[0]
     else:
         tabName = XbrlConst.baseSetArcroleLabel(arcrole)[1:]
     super(ViewRelationshipSet, self).__init__(modelXbrl, tabWin, tabName, True, lang)
     self.arcrole = arcrole
     self.linkrole = linkrole
     self.linkqname = linkqname
     self.arcqname = arcqname
     self.treeColHdr = treeColHdr
     self.isResourceArcrole = False
开发者ID:andygreener,项目名称:Arelle,代码行数:12,代码来源:ViewWinRelationshipSet.py

示例7: view

    def view(self, arcrole, linkrole=None, linkqname=None, arcqname=None):
        # determine relationships indent depth for dimensions linkbases
        # set up treeView widget and tabbed pane
        if arcrole == XbrlConst.parentChild: # extra columns
            heading = ["Presentation Relationships", "Pref. Label", "Type", "References"]
        elif arcrole == XbrlConst.summationItem:    # add columns for calculation relationships
            heading = ["Calculation Relationships", "Weight", "Balance"]
        elif arcrole == "XBRL-dimensions":    # add columns for dimensional information
            heading = ["Dimensions Relationships", "Arcrole","CntxElt","Closed","Usable"]
        elif isinstance(arcrole, (list,tuple)) or XbrlConst.isResourceArcrole(arcrole):
            self.isResourceArcrole = True
            self.showReferences = isinstance(arcrole, _STR_BASE) and arcrole.endswith("-reference")
            heading = ["Resource Relationships", "Arcrole","Resource","ResourceRole","Language"]
        else:
            heading = [os.path.basename(arcrole).title() + " Relationships"]
        # relationship set based on linkrole parameter, to determine applicable linkroles
        relationshipSet = self.modelXbrl.relationshipSet(arcrole, linkrole, linkqname, arcqname)

        self.arcrole = arcrole
        
        if relationshipSet:
            # sort URIs by definition
            linkroleUris = []
            for linkroleUri in relationshipSet.linkRoleUris:
                modelRoleTypes = self.modelXbrl.roleTypes.get(linkroleUri)
                if modelRoleTypes:
                    roledefinition = (modelRoleTypes[0].genLabel(lang=self.lang, strip=True) or modelRoleTypes[0].definition or linkroleUri)                    
                else:
                    roledefinition = linkroleUri
                linkroleUris.append((roledefinition, linkroleUri))
            linkroleUris.sort()
    
            for roledefinition, linkroleUri in linkroleUris:
                linkRelationshipSet = self.modelXbrl.relationshipSet(arcrole, linkroleUri, linkqname, arcqname)
                for rootConcept in linkRelationshipSet.rootConcepts:
                    self.treeDepth(rootConcept, rootConcept, 2, arcrole, linkRelationshipSet, set())
                    
        self.addRow(heading, asHeader=True) # must do after determining tree depth
        
        if relationshipSet:
            # for each URI in definition order
            for roledefinition, linkroleUri in linkroleUris:
                attr = {"role": linkroleUri}
                self.addRow([roledefinition], treeIndent=0, colSpan=len(heading), 
                            xmlRowElementName="linkRole", xmlRowEltAttr=attr, xmlCol0skipElt=True)
                linkRelationshipSet = self.modelXbrl.relationshipSet(arcrole, linkroleUri, linkqname, arcqname)
                for rootConcept in linkRelationshipSet.rootConcepts:
                    self.viewConcept(rootConcept, rootConcept, "", self.labelrole, 1, arcrole, linkRelationshipSet, set())
开发者ID:DaveInga,项目名称:Arelle,代码行数:48,代码来源:ViewFileRelationshipSet.py

示例8: insertResources

 def insertResources(self):
     self.showStatus("insert resources")
     # deduplicate resources (may be on multiple arcs)
     # note that lxml has no column numbers, use objectIndex as pseudo-column number
     uniqueResources = dict(((self.documentIds[resource.modelDocument.uri],
                              resource.sourceline,
                              resource.objectIndex), resource)
                            for arcrole in (XbrlConst.conceptLabel, XbrlConst.conceptReference)
                            for rel in self.modelXbrl.relationshipSet(arcrole).modelRelationships
                            if rel.fromModelObject is not None and rel.toModelObject is not None
                            for resource in (rel.fromModelObject, rel.toModelObject)
                            if isinstance(resource, ModelResource))
     table = self.getTable('resource', 'resource_id', 
                           ('role_uri_id', 'qname_id', 'document_id', 'document_line_number', 'document_column_number'), 
                           ('document_id', 'document_line_number', 'document_column_number'), 
                           tuple((self.uriId[resource.role],
                                  self.qnameId[resource.qname],
                                  self.documentIds[resource.modelDocument.uri],
                                  resource.sourceline,
                                  resource.objectIndex)
                                 for resource in uniqueResources.values()),
                           checkIfExisting=True)
     self.resourceId = dict(((docId, line, offset), id)
                            for id, docId, line, offset in table)
     
     self.showStatus("insert labels")
     table = self.getTable('label_resource', 'resource_id', 
                           ('resource_id', 'label', 'xml_lang'), 
                           ('resource_id',), 
                           tuple((self.resourceId[self.documentIds[resource.modelDocument.uri],
                                                  resource.sourceline,
                                                  resource.objectIndex],
                                  resource.textValue,
                                  resource.xmlLang)
                                 for arcrole in (XbrlConst.conceptLabel, XbrlConst.conceptReference)
                                 for rel in self.modelXbrl.relationshipSet(arcrole).modelRelationships
                                 if rel.fromModelObject is not None and rel.toModelObject is not None
                                 for resource in (rel.fromModelObject, rel.toModelObject)
                                 if isinstance(resource, ModelResource) and XbrlConst.isLabelRole(resource.role)),
                           checkIfExisting=True)
开发者ID:GuoHuiChen,项目名称:Arelle,代码行数:40,代码来源:XbrlPublicPostgresDB.py

示例9: init

def init(modelXbrl):
    # setup modelXbrl for rendering evaluation

    # dimension defaults required in advance of validation
    from arelle import ValidateXbrlDimensions, ValidateFormula, ModelDocument
    ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
    
    hasXbrlTables = False
    
    # validate table linkbase dimensions
    for baseSetKey in modelXbrl.baseSets.keys():
        arcrole, ELR, linkqname, arcqname = baseSetKey
        if ELR and linkqname and arcqname and XbrlConst.isTableRenderingArcrole(arcrole):
            ValidateFormula.checkBaseSet(modelXbrl, arcrole, ELR, modelXbrl.relationshipSet(arcrole,ELR,linkqname,arcqname))
            if arcrole in (XbrlConst.tableBreakdown, XbrlConst.tableBreakdownMMDD, XbrlConst.tableBreakdown201305, XbrlConst.tableBreakdown201301, XbrlConst.tableAxis2011):
                hasXbrlTables = True

    # provide context for view
    if modelXbrl.modelDocument.type == ModelDocument.Type.INSTANCE:
        instance = None # use instance of the entry pont
    else: # need dummy instance
        instance = ModelDocument.create(modelXbrl, ModelDocument.Type.INSTANCE, 
                                        "dummy.xml",  # fake URI and fake schemaRef 
                                        ("http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd",))
        
    if hasXbrlTables:
        # formula processor is needed for 2011 XBRL tables but not for 2010 Eurofiling tables
        modelXbrl.rendrCntx = XPathContext.create(modelXbrl, instance)
        
        modelXbrl.profileStat(None)
        
        # setup fresh parameters from formula options
        modelXbrl.parameters = modelXbrl.modelManager.formulaOptions.typedParameters()
        
        # validate parameters and custom function signatures
        ValidateFormula.validate(modelXbrl, xpathContext=modelXbrl.rendrCntx, parametersOnly=True, statusMsg=_("compiling rendering tables"))
        
        # deprecated as of 2013-05-17
        # check and extract message expressions into compilable programs
        for msgArcrole in (XbrlConst.tableDefinitionNodeMessage201301, XbrlConst.tableDefinitionNodeSelectionMessage201301,
                           XbrlConst.tableAxisMessage2011, XbrlConst.tableAxisSelectionMessage2011):
            for msgRel in modelXbrl.relationshipSet(msgArcrole).modelRelationships:
                ValidateFormula.checkMessageExpressions(modelXbrl, msgRel.toModelObject)
                
        # compile and validate tables
        for modelTable in modelXbrl.modelRenderingTables:
            modelTable.fromInstanceQnames = None # required if referred to by variables scope chaining
            modelTable.compile()

            hasNsWithAspectModel = modelTable.namespaceURI in (XbrlConst.euRend, XbrlConst.table2011, XbrlConst.table201301, XbrlConst.table201305) 
        
            # check aspectModel  (attribute removed 2013-06, now always dimensional)
            if modelTable.aspectModel not in ("non-dimensional", "dimensional") and hasNsWithAspectModel:
                modelXbrl.error("xbrlte:unknownAspectModel",
                    _("Table %(xlinkLabel)s, aspect model %(aspectModel)s not recognized"),
                    modelObject=modelTable, xlinkLabel=modelTable.xlinkLabel, aspectModel=modelTable.aspectModel)
            else:
                modelTable.priorAspectAxisDisposition = {}
                # check ordinate aspects against aspectModel
                oppositeAspectModel = (_DICT_SET({'dimensional','non-dimensional'}) - _DICT_SET({modelTable.aspectModel})).pop()
                if hasNsWithAspectModel:
                    uncoverableAspects = aspectModels[oppositeAspectModel] - aspectModels[modelTable.aspectModel]
                else:
                    uncoverableAspects = ()
                aspectsCovered = set()
                for tblAxisRel in modelXbrl.relationshipSet((XbrlConst.tableBreakdown, XbrlConst.tableBreakdownMMDD, XbrlConst.tableBreakdown201305, XbrlConst.tableBreakdown201301,XbrlConst.tableAxis2011)).fromModelObject(modelTable):
                    breakdownAspectsCovered = set()
                    hasCoveredAspect = checkBreakdownDefinitionNode(modelXbrl, modelTable, tblAxisRel, tblAxisRel.axisDisposition, uncoverableAspects, breakdownAspectsCovered)
                    ''' removed 2013-10
                    if not hasCoveredAspect:
                        definitionNode = tblAxisRel.toModelObject
                        modelXbrl.error("xbrlte:breakdownDefinesNoAspects",
                            _("Breakdown %(xlinkLabel)s has no participating aspects"),
                            modelObject=(modelTable,definitionNode), xlinkLabel=definitionNode.xlinkLabel, axis=definitionNode.localName)
                    '''
                    aspectsCovered |= breakdownAspectsCovered
                    checkBreakdownLeafNodeAspects(modelXbrl, modelTable, tblAxisRel, set(), breakdownAspectsCovered)
                if Aspect.CONCEPT not in aspectsCovered and not hasNsWithAspectModel:
                    modelXbrl.error("xbrlte:tableMissingConceptAspect",
                        _("Table %(xlinkLabel)s does not include the concept aspect as one of its participating aspects"),
                        modelObject=modelTable, xlinkLabel=modelTable.xlinkLabel)
                del modelTable.priorAspectAxisDisposition
                # check for table-parameter name clash
                parameterNames = {}
                for tblParamRel in modelXbrl.relationshipSet((XbrlConst.tableParameter, XbrlConst.tableParameterMMDD)).fromModelObject(modelTable):
                    parameterName = tblParamRel.variableQname
                    if parameterName in parameterNames:
                        modelXbrl.error("xbrlte:tableParameterNameClash ",
                            _("Table %(xlinkLabel)s has parameter name clash for variable %(name)s"),
                            modelObject=(modelTable,tblParamRel,parameterNames[parameterName]), xlinkLabel=modelTable.xlinkLabel, name=parameterName)
                    else:
                        parameterNames[parameterName] = tblParamRel
    
        modelXbrl.profileStat(_("compileTables"))
开发者ID:JTYim,项目名称:Arelle,代码行数:94,代码来源:RenderingEvaluator.py

示例10: view

 def view(self, firstTime=False):
     self.blockSelectEvent = 1
     self.blockViewModelObject = 0
     self.tag_has = defaultdict(list) # temporary until Tk 8.6
     # relationship set based on linkrole parameter, to determine applicable linkroles
     relationshipSet = self.modelXbrl.relationshipSet(self.arcrole, self.linkrole, self.linkqname, self.arcqname)
     if not relationshipSet:
         self.modelXbrl.modelManager.addToLog(_("no relationships for {0}").format(self.arcrole))
         return False
     
     if firstTime:
         # set up treeView widget and tabbed pane
         hdr = self.treeColHdr if self.treeColHdr else _("{0} Relationships").format(XbrlConst.baseSetArcroleLabel(self.arcrole)[1:])
         self.treeView.heading("#0", text=hdr)
         if self.arcrole == XbrlConst.parentChild: # extra columns
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("type", "references")
             self.treeView.column("type", width=100, anchor="w", stretch=False)
             self.treeView.heading("type", text=_("Type"))
             self.treeView.column("references", width=200, anchor="w", stretch=False)
             self.treeView.heading("references", text=_("References"))
         elif self.arcrole == XbrlConst.summationItem: # extra columns
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("weight", "balance")
             self.treeView.column("weight", width=48, anchor="w", stretch=False)
             self.treeView.heading("weight", text=_("Weight"))
             self.treeView.column("balance", width=70, anchor="w", stretch=False)
             self.treeView.heading("balance", text=_("Balance"))
         elif self.arcrole == "XBRL-dimensions":    # add columns for dimensional information
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("arcrole", "contextElement", "closed", "usable")
             self.treeView.column("arcrole", width=100, anchor="w", stretch=False)
             self.treeView.heading("arcrole", text="Arcrole")
             self.treeView.column("contextElement", width=50, anchor="center", stretch=False)
             self.treeView.heading("contextElement", text="Context")
             self.treeView.column("closed", width=40, anchor="center", stretch=False)
             self.treeView.heading("closed", text="Closed")
             self.treeView.column("usable", width=40, anchor="center", stretch=False)
             self.treeView.heading("usable", text="Usable")
         elif self.arcrole == "Table-rendering":    # add columns for dimensional information
             self.treeView.column("#0", width=160, anchor="w")
             self.treeView["columns"] = ("axis", "abstract", "header", "priItem", "dims")
             self.treeView.column("axis", width=50, anchor="center", stretch=False)
             self.treeView.heading("axis", text="Axis")
             self.treeView.column("abstract", width=24, anchor="center", stretch=False)
             self.treeView.heading("abstract", text="Abs")
             self.treeView.column("header", width=160, anchor="w", stretch=False)
             self.treeView.heading("header", text="Header")
             self.treeView.column("priItem", width=100, anchor="w", stretch=False)
             self.treeView.heading("priItem", text="Primary Item")
             self.treeView.column("dims", width=150, anchor="w", stretch=False)
             self.treeView.heading("dims", text=_("Dimensions"))
     self.id = 1
     for previousNode in self.treeView.get_children(""): 
         self.treeView.delete(previousNode)
     # sort URIs by definition
     linkroleUris = []
     for linkroleUri in relationshipSet.linkRoleUris:
         modelRoleTypes = self.modelXbrl.roleTypes.get(linkroleUri)
         if modelRoleTypes:
             roledefinition = modelRoleTypes[0].definition
             if not roledefinition:
                 roledefinition = linkroleUri                    
             roleId = modelRoleTypes[0].objectId(self.id)
         else:
             roledefinition = linkroleUri
             roleId = "node{0}".format(self.id)
         self.id += 1
         linkroleUris.append((roledefinition, linkroleUri, roleId))
     linkroleUris.sort()
     # for each URI in definition order
     for linkroleUriTuple in linkroleUris:
         linknode = self.treeView.insert("", "end", linkroleUriTuple[2], text=linkroleUriTuple[0], tags=("ELR",))
         linkRelationshipSet = self.modelXbrl.relationshipSet(self.arcrole, linkroleUriTuple[1], self.linkqname, self.arcqname)
         for rootConcept in linkRelationshipSet.rootConcepts:
             self.viewConcept(rootConcept, rootConcept, "", self.labelrole, linknode, 1, linkRelationshipSet, set())
             self.tag_has[linkroleUriTuple[1]].append(linknode)
开发者ID:marado,项目名称:Arelle,代码行数:77,代码来源:ViewWinRelationshipSet.py

示例11: validate


#.........这里部分代码省略.........
                    self.modelVersReport.error("vercbe:invalidConceptReference",
                        _("%(event)s toConcept %(concept)s does not reference a concept in toDTS"),
                        modelObject=conceptChange, event=conceptChange.name, concept=conceptChange.toConceptQname) 
                    
            # check concept changes of concept extended
            for conceptChange in versReport.conceptExtendedChanges:
                fromConcept = conceptChange.fromConcept
                toConcept = conceptChange.toConcept
                fromResource = conceptChange.fromResource
                toResource = conceptChange.toResource
                # fromConcept checks
                if not conceptChange.name.endswith("Add"):
                    if not fromConcept is not None:
                        self.modelVersReport.error("vercbe:invalidConceptReference",
                            _("%(action)s %(event)s fromConcept %(concept)s does not reference a concept in fromDTS"),
                            modelObject=conceptChange, action=conceptChange.actionId,
                            event=conceptChange.name, concept=conceptChange.fromConceptQname) 
                    # tuple check
                    elif _("Child") in conceptChange.name and \
                        not versReport.fromDTS.qnameConcepts[fromConcept.qname] \
                            .isTuple:
                        self.modelVersReport.error("vercbe:invalidConceptReference",
                            _("%(action)s %(event)s fromConcept %(concept)s must be defined as a tuple"),
                            modelObject=conceptChange, action=conceptChange.actionId,
                            event=conceptChange.name, concept=conceptChange.fromConceptQname) 
                    # resource check
                    elif "Label" in conceptChange.name:
                        if fromResource is None:
                            self.modelVersReport.error("vercee:invalidContentResourceIdentifier",
                                _("%(action)s %(event)s fromResource %(resource)s does not reference a resource in fromDTS"),
                                modelObject=conceptChange, action=conceptChange.actionId,
                                event=conceptChange.name, resource=conceptChange.fromResourceValue) 
                        else:
                            relationship = fromConcept.relationshipToResource(fromResource, XbrlConst.conceptLabel)
                            if relationship is not None:
                                if relationship.qname != XbrlConst.qnLinkLabelArc or \
                                   relationship.parentQname != XbrlConst.qnLinkLabelLink or \
                                   fromResource.qname != XbrlConst.qnLinkLabel:
                                    self.modelVersReport.error("vercee:invalidConceptLabelIdentifier",
                                        _("%(action)s %(event)s fromResource %(resource)s for %(concept)s in fromDTS does not have expected link, arc, or label elements"),
                                        modelObject=conceptChange, action=conceptChange.actionId,
                                        event=conceptChange.name, resource=conceptChange.fromResourceValue, concept=conceptChange.fromConceptQname)
                            else:
                                relationship = fromConcept.relationshipToResource(fromResource, XbrlConst.elementLabel)
                                if relationship is not None:
                                    if relationship.qname != XbrlConst.qnGenArc or \
                                       fromResource.qname != XbrlConst.qnGenLabel:
                                        self.modelVersReport.error("vercee:invalidConceptLabelIdentifier",
                                            _("%(action)s %(event)s fromResource %(resource)s for %(concept)s in fromDTS does not have expected link, arc, or label elements"),
                                            modelObject=conceptChange, action=conceptChange.actionId,
                                            event=conceptChange.name, resource=conceptChange.fromResourceValue, concept=conceptChange.fromConceptQname)
                                else:
                                    self.modelVersReport.error("vercee:invalidContentResourceIdentifier",
                                        _("%(action)s %(event)s fromResource %(resource)s does not have a label relationship to {3} in fromDTS"),
                                        modelObject=conceptChange, action=conceptChange.actionId,
                                        event=conceptChange.name, resource=conceptChange.fromResourceValue)
                    elif "Reference" in conceptChange.name:
                        if fromResource is None:
                            self.modelVersReport.error("vercee:invalidContentResourceIdentifier",
                                _("%(action)s %(event)s fromResource %(resource)s does not reference a resource in fromDTS"),
                                modelObject=conceptChange, action=conceptChange.actionId,
                                event=conceptChange.name, resource=conceptChange.fromResourceValue)
                        else:
                            relationship = fromConcept.relationshipToResource(fromResource, XbrlConst.conceptReference)
                            if relationship is not None:
                                if relationship.qname != XbrlConst.qnLinkReferenceArc or \
开发者ID:Bourne-Law,项目名称:Arelle,代码行数:67,代码来源:ValidateVersReport.py

示例12: linkbaseDiscover

 def linkbaseDiscover(self, linkbaseElement, inInstance=False):
     for lbElement in linkbaseElement.iterchildren():
         if isinstance(lbElement,ModelObject):
             lbLn = lbElement.localName
             lbNs = lbElement.namespaceURI
             if lbNs == XbrlConst.link:
                 if lbLn == "roleRef" or lbLn == "arcroleRef":
                     href = self.discoverHref(lbElement)
                     if href is None:
                         self.modelXbrl.error("xbrl:hrefMissing",
                                 _("Linkbase reference for %(linkbaseRefElement)s href attribute missing or malformed"),
                                 modelObject=lbElement, linkbaseRefElement=lbLn)
                     else:
                         self.hrefObjects.append(href)
                     continue
             if lbElement.get("{http://www.w3.org/1999/xlink}type") == "extended":
                 if isinstance(lbElement, ModelLink):
                     self.schemalocateElementNamespace(lbElement)
                     arcrolesFound = set()
                     dimensionArcFound = False
                     formulaArcFound = False
                     tableRenderingArcFound = False
                     linkQn = qname(lbElement)
                     linkrole = lbElement.get("{http://www.w3.org/1999/xlink}role")
                     isStandardExtLink = XbrlConst.isStandardResourceOrExtLinkElement(lbElement)
                     if inInstance:
                         #index footnote links even if no arc children
                         baseSetKeys = (("XBRL-footnotes",None,None,None), 
                                        ("XBRL-footnotes",linkrole,None,None))
                         for baseSetKey in baseSetKeys:
                             self.modelXbrl.baseSets[baseSetKey].append(lbElement)
                     for linkElement in lbElement.iterchildren():
                         if isinstance(linkElement,ModelObject):
                             self.schemalocateElementNamespace(linkElement)
                             xlinkType = linkElement.get("{http://www.w3.org/1999/xlink}type")
                             modelResource = None
                             if xlinkType == "locator":
                                 nonDTS = linkElement.namespaceURI != XbrlConst.link or linkElement.localName != "loc"
                                 # only link:loc elements are discovered or processed
                                 href = self.discoverHref(linkElement, nonDTS=nonDTS)
                                 if href is None:
                                     if isStandardExtLink:
                                         self.modelXbrl.error("xbrl:hrefMissing",
                                                 _("Locator href attribute missing or malformed in standard extended link"),
                                                 modelObejct=linkElement)
                                     else:
                                         self.modelXbrl.warning("arelle:hrefWarning",
                                                 _("Locator href attribute missing or malformed in non-standard extended link"),
                                                 modelObejct=linkElement)
                                 else:
                                     linkElement.modelHref = href
                                     modelResource = linkElement
                             elif xlinkType == "arc":
                                 arcQn = qname(linkElement)
                                 arcrole = linkElement.get("{http://www.w3.org/1999/xlink}arcrole")
                                 if arcrole not in arcrolesFound:
                                     if linkrole == "":
                                         linkrole = XbrlConst.defaultLinkRole
                                     #index by both arcrole and linkrole#arcrole and dimensionsions if applicable
                                     baseSetKeys = [(arcrole, linkrole, linkQn, arcQn)]
                                     baseSetKeys.append((arcrole, linkrole, None, None))
                                     baseSetKeys.append((arcrole, None, None, None))
                                     if XbrlConst.isDimensionArcrole(arcrole) and not dimensionArcFound:
                                         baseSetKeys.append(("XBRL-dimensions", None, None, None)) 
                                         baseSetKeys.append(("XBRL-dimensions", linkrole, None, None))
                                         dimensionArcFound = True
                                     if XbrlConst.isFormulaArcrole(arcrole) and not formulaArcFound:
                                         baseSetKeys.append(("XBRL-formulae", None, None, None)) 
                                         baseSetKeys.append(("XBRL-formulae", linkrole, None, None))
                                         formulaArcFound = True
                                     if XbrlConst.isTableRenderingArcrole(arcrole) and not tableRenderingArcFound:
                                         baseSetKeys.append(("Table-rendering", None, None, None)) 
                                         baseSetKeys.append(("Table-rendering", linkrole, None, None)) 
                                         tableRenderingArcFound = True
                                         self.modelXbrl.hasTableRendering = True
                                     for baseSetKey in baseSetKeys:
                                         self.modelXbrl.baseSets[baseSetKey].append(lbElement)
                                     arcrolesFound.add(arcrole)
                             elif xlinkType == "resource": 
                                 # create resource and make accessible by id for document
                                 modelResource = linkElement
                             if modelResource is not None:
                                 lbElement.labeledResources[linkElement.get("{http://www.w3.org/1999/xlink}label")] \
                                     .append(modelResource)
                 else:
                     self.modelXbrl.error("xbrl:schemaDefinitionMissing",
                             _("Linkbase extended link %(element)s missing schema definition"),
                             modelObject=lbElement, element=lbElement.prefixedName)
开发者ID:marado,项目名称:Arelle,代码行数:88,代码来源:ModelDocument.py

示例13: groupRelationshipLabel

def groupRelationshipLabel(arcrole):
    if isinstance(arcrole, (list,tuple)): # (group-name, [arcroles])
        arcroleName = arcrole[0]
    else:
        arcroleName = XbrlConst.baseSetArcroleLabel(arcrole)[1:]
    return arcroleName
开发者ID:Arelle,项目名称:Arelle,代码行数:6,代码来源:ViewUtil.py

示例14: init

def init(modelXbrl):
    # setup modelXbrl for rendering evaluation

    # dimension defaults required in advance of validation
    from arelle import ValidateXbrlDimensions, ValidateFormula, ModelDocument
    ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
    
    hasXbrlTables = False
    
    # validate table linkbase dimensions
    for baseSetKey in modelXbrl.baseSets.keys():
        arcrole, ELR, linkqname, arcqname = baseSetKey
        if ELR and linkqname and arcqname and XbrlConst.isTableRenderingArcrole(arcrole):
            ValidateFormula.checkBaseSet(modelXbrl, arcrole, ELR, modelXbrl.relationshipSet(arcrole,ELR,linkqname,arcqname))
            if arcrole in (XbrlConst.tableBreakdown, XbrlConst.tableAxis2011):
                hasXbrlTables = True

    # provide context for view
    if modelXbrl.modelDocument.type == ModelDocument.Type.INSTANCE:
        instance = None # use instance of the entry pont
    else: # need dummy instance
        instance = ModelDocument.create(modelXbrl, ModelDocument.Type.INSTANCE, 
                                        "dummy.xml",  # fake URI and fake schemaRef 
                                        ("http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd",))
        
    if hasXbrlTables:
        # formula processor is needed for 2011 XBRL tables but not for 2010 Eurofiling tables
        modelXbrl.rendrCntx = XPathContext.create(modelXbrl, instance)
        
        modelXbrl.profileStat(None)
        
        # setup fresh parameters from formula optoins
        modelXbrl.parameters = modelXbrl.modelManager.formulaOptions.typedParameters()
        
        # validate parameters and custom function signatures
        ValidateFormula.validate(modelXbrl, xpathContext=modelXbrl.rendrCntx, parametersOnly=True, statusMsg=_("compiling rendering tables"))
        
        # check and extract message expressions into compilable programs
        for msgArcrole in (XbrlConst.tableDefinitionNodeMessage, XbrlConst.tableDefinitionNodeSelectionMessage,
                           XbrlConst.tableAxisMessage2011, XbrlConst.tableAxisSelectionMessage2011):
            for msgRel in modelXbrl.relationshipSet(msgArcrole).modelRelationships:
                ValidateFormula.checkMessageExpressions(modelXbrl, msgRel.toModelObject)
                
        # compile and validate tables
        for modelTable in modelXbrl.modelRenderingTables:
            modelTable.fromInstanceQnames = None # required if referred to by variables scope chaining
            modelTable.compile()

            # check aspectModel
            if modelTable.aspectModel not in ("non-dimensional", "dimensional"):
                modelXbrl.error("xbrlte:unknownAspectModel",
                    _("Table %(xlinkLabel)s, aspect model %(aspectModel)s not recognized"),
                    modelObject=modelTable, xlinkLabel=modelTable.xlinkLabel, aspectModel=modelTable.aspectModel)
            else:
                modelTable.priorAspectAxisDisposition = {}
                # check ordinate aspects against aspectModel
                oppositeAspectModel = (_DICT_SET({'dimensional','non-dimensional'}) - _DICT_SET({modelTable.aspectModel})).pop()
                uncoverableAspects = aspectModels[oppositeAspectModel] - aspectModels[modelTable.aspectModel]
                for tblAxisRel in modelXbrl.relationshipSet((XbrlConst.tableBreakdown,XbrlConst.tableAxis2011)).fromModelObject(modelTable):
                    checkDefinitionNodeAspectModel(modelXbrl, modelTable, tblAxisRel, uncoverableAspects)
                del modelTable.priorAspectAxisDisposition
    
        modelXbrl.profileStat(_("compileTables"))
开发者ID:benrosemeyer-wf,项目名称:Arelle,代码行数:63,代码来源:RenderingEvaluator.py

示例15: presumptionOfTotal

def presumptionOfTotal(val, rel, siblingRels, iSibling, isStatementSheet, nestedInTotal, checkLabelRoleOnly):
    """
    A numeric concept target of a parent-child relationship is presumed total if:
    
    (i) its preferredLabel role is a total role (pre XbrlConst static function of 
    current such total roles) or
    
    (ii) if not in a nested total (abstract child relationship to a known total's 
    contributing siblings):
    
    the parent is not SupplementalCashFlowInformationAbstract and the preceding 
    sibling relationship is monetary and it's on a statement sheet and it's the 
    last of more than one monetary item
    
    (a) Last monetary parented by an abstract or non-monetary and not in a nested 
    (breakdown) total, or 
    (b) effective label (en-US of preferred role) has "Total" in its wording.
    (c) (commented out for now due to false positives: Concept name has "Total" 
    in its name)
    (d) last monetary (may be sub level) whose immediate sibling is a calc LB child
    """
    concept = rel.toModelObject
    if isinstance(concept, ModelConcept) and concept.isNumeric:
        preferredLabel = rel.preferredLabel
        if XbrlConst.isTotalRole(preferredLabel):
            return _("preferredLabel {0}").format(os.path.basename(preferredLabel))
        if concept.isMonetary and not checkLabelRoleOnly: 
            effectiveLabel = concept.label(lang="en-US", fallbackToQname=False, preferredLabel=preferredLabel)
            ''' word total in label/name does not seem to be a good indicator, 
                e.g., Google Total in label for ShareBasedCompensationArrangementByShareBasedPaymentAwardGrantDateFairValueOfOptionsVested followed by 
                label with Aggregate but name has Total
                ... so only perform this test on last monetary in a Note 
            if 'Total' in effectiveLabel: # also check for Net ???
                return _("word 'Total' in effective label {0}").format(effectiveLabel)
            if 'Total' in concept.name: # also check for Net ???
                return _("word 'Total' in concept name {0}").format(concept.name)
            '''
            parent = rel.fromModelObject
            if (len(siblingRels) > 1 and
                iSibling == len(siblingRels) - 1 and 
                parent is not None and
                parent.name not in {
                    "SupplementalCashFlowInformationAbstract"
                }):
                preceedingSibling = siblingRels[iSibling - 1].toModelObject
                if preceedingSibling is not None and preceedingSibling.isMonetary:
                    # last fact, may be total
                    if isStatementSheet:
                        # check if facts add up??
                        if (parent.isAbstract or not parent.isMonetary) and not nestedInTotal:
                            return _("last monetary item in statement sheet monetary line items parented by nonMonetary concept")
                        elif effectiveLabel and 'Total' in effectiveLabel: 
                            return _("last monetary item in statement sheet monetary line items with word 'Total' in effective label {0}").format(effectiveLabel)
                        elif 'Total' in concept.name:
                            return _("last monetary item in statement sheet monetary line items with word 'Total' in concept name {0}").format(concept.name)
                        elif val.summationItemRelsSetAllELRs.isRelated(concept, "child", preceedingSibling):
                            return _("last monetary item in statement sheet monetary line items is calc sum of previous line item")
                    ''' for now unreliable to use total words for notes
                    else:
                        if 'Total' in effectiveLabel: # also check for Net ???
                            return _("last monetary item in note with word 'Total' in effective label {0}").format(effectiveLabel)
                        if 'Total' in concept.name: # also check for Net ???
                            return _("last monetary item in note with word 'Total' in concept name {0}").format(concept.name)
                    '''
    return None
开发者ID:Arelle,项目名称:Arelle,代码行数:65,代码来源:PreCalAlignment.py


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