Exemple #1
0
 def label(self,preferredLabel=None,fallbackToQname=True,lang=None,strip=False,linkrole=None):
     if preferredLabel is None: preferredLabel = XbrlConst.standardLabel
     if preferredLabel == XbrlConst.conceptNameLabelRole: return str(self.qname)
     labelsRelationshipSet = self.modelXbrl.relationshipSet(XbrlConst.conceptLabel,linkrole)
     if labelsRelationshipSet:
         label = labelsRelationshipSet.label(self, preferredLabel, lang)
         if label is not None:
             if strip: return label.strip()
             return Locale.rtlString(label, lang=lang)
     return str(self.qname) if fallbackToQname else None
Exemple #2
0
 def genLabel(self,role=None,fallbackToQname=False,fallbackToXlinkLabel=False,lang=None,strip=False,linkrole=None, linkroleHint=None):
     from arelle import XbrlConst
     if role is None: role = XbrlConst.genStandardLabel
     if role == XbrlConst.conceptNameLabelRole: return str(self.qname)
     labelsRelationshipSet = self.modelXbrl.relationshipSet(XbrlConst.elementLabel,linkrole)
     if labelsRelationshipSet:
         label = labelsRelationshipSet.label(self, linkroleHint or role, lang)
         if label is not None:
             if strip: return label.strip()
             return Locale.rtlString(label, lang=lang)
     if fallbackToQname:
         return str(self.qname)
     elif fallbackToXlinkLabel and hasattr(self,"xlinkLabel"):
         return self.xlinkLabel
     else:
         return None
Exemple #3
0
 def label(self,
           preferredLabel=None,
           fallbackToQname=True,
           lang=None,
           strip=False,
           linkrole=None):
     if preferredLabel is None: preferredLabel = XbrlConst.standardLabel
     if preferredLabel == XbrlConst.conceptNameLabelRole:
         return str(self.qname)
     labelsRelationshipSet = self.modelXbrl.relationshipSet(
         XbrlConst.conceptLabel, linkrole)
     if labelsRelationshipSet:
         label = labelsRelationshipSet.label(self, preferredLabel, lang)
         if label is not None:
             if strip: return label.strip()
             return Locale.rtlString(label, lang=lang)
     return str(self.qname) if fallbackToQname else None
 def viewConcept(self, concept, modelObject, labelPrefix, preferredLabel, parentnode, n, relationshipSet, visited):
     if concept is None:
         return
     try:
         isRelation = isinstance(modelObject, ModelDtsObject.ModelRelationship)
         if isinstance(concept, ModelDtsObject.ModelConcept):
             text = labelPrefix + concept.label(preferredLabel,lang=self.lang,linkroleHint=relationshipSet.linkrole)
             if (self.arcrole in ("XBRL-dimensions", XbrlConst.hypercubeDimension) and
                 concept.isTypedDimension and 
                 concept.typedDomainElement is not None):
                 text += " (typedDomain={0})".format(concept.typedDomainElement.qname)  
         elif isinstance(concept, ModelInstanceObject.ModelFact):
             if concept.concept is not None:
                 text = labelPrefix + concept.concept.label(preferredLabel,lang=self.lang,linkroleHint=relationshipSet.linkrole)
             else:
                 text = str(concept.qname)
             if concept.contextID:
                 text += " [" + concept.contextID + "] = " + concept.effectiveValue
         elif self.arcrole == "Table-rendering":
             text = concept.localName
         elif isinstance(concept, ModelRenderingObject.ModelTable):
             text = (concept.genLabel(lang=self.lang, strip=True) or concept.localName)
         elif isinstance(concept, ModelDtsObject.ModelResource):
             if self.showReferences:
                 text = (concept.viewText() or concept.localName)
             else:
                 text = (Locale.rtlString(concept.textValue.strip(), lang=concept.xmlLang) or concept.localName)
         else:   # just a resource
             text = concept.localName
         childnode = self.treeView.insert(parentnode, "end", modelObject.objectId(self.id), text=text, tags=("odd" if n & 1 else "even",))
         childRelationshipSet = relationshipSet
         if self.arcrole == XbrlConst.parentChild: # extra columns
             if isRelation:
                 preferredLabel = modelObject.preferredLabel
                 if preferredLabel and preferredLabel.startswith("http://www.xbrl.org/2003/role/"):
                     preferredLabel = os.path.basename(preferredLabel)
                 self.treeView.set(childnode, "preferredLabel", preferredLabel)
             self.treeView.set(childnode, "type", concept.niceType)
             self.treeView.set(childnode, "references", viewReferences(concept))
         elif self.arcrole == XbrlConst.summationItem:
             if isRelation:
                 self.treeView.set(childnode, "weight", "{:+0g} ".format(modelObject.weight))
             self.treeView.set(childnode, "balance", concept.balance)
         elif self.arcrole == "XBRL-dimensions" and isRelation: # extra columns
             relArcrole = modelObject.arcrole
             self.treeView.set(childnode, "arcrole", os.path.basename(relArcrole))
             if relArcrole in (XbrlConst.all, XbrlConst.notAll):
                 self.treeView.set(childnode, "contextElement", modelObject.contextElement)
                 self.treeView.set(childnode, "closed", modelObject.closed)
             elif relArcrole in (XbrlConst.dimensionDomain, XbrlConst.domainMember):
                 self.treeView.set(childnode, "usable", modelObject.usable)
             childRelationshipSet = self.modelXbrl.relationshipSet(XbrlConst.consecutiveArcrole.get(relArcrole,"XBRL-dimensions"),
                                                                   modelObject.consecutiveLinkrole)
         elif self.arcrole == "Table-rendering": # extra columns
             try:
                 header = concept.header(lang=self.lang,strip=True,evaluate=False)
             except AttributeError:
                 header = None # could be a filter
             if isRelation and header is None:
                 header = "{0} {1}".format(os.path.basename(modelObject.arcrole), concept.xlinkLabel)
             self.treeView.set(childnode, "header", header)
             if concept.get("abstract") == "true":
                 self.treeView.set(childnode, "abstract", '\u2713') # checkmark unicode character
             if concept.get("merge") == "true":
                 self.treeView.set(childnode, "merge", '\u2713') # checkmark unicode character
             if isRelation:
                 self.treeView.set(childnode, "axis", modelObject.axisDisposition)
                 if isinstance(concept, (ModelEuAxisCoord,ModelRuleDefinitionNode)):
                     self.treeView.set(childnode, "priItem", concept.aspectValue(None, Aspect.CONCEPT))
                     self.treeView.set(childnode, "dims", ' '.join(("{0},{1}".format(dim, concept.aspectValue(None, dim)) 
                                                                    for dim in (concept.aspectValue(None, Aspect.DIMENSIONS, inherit=False) or []))))
         elif self.isResourceArcrole: # resource columns
             if isRelation:
                 self.treeView.set(childnode, "arcrole", os.path.basename(modelObject.arcrole))
             if isinstance(concept, ModelDtsObject.ModelResource):
                 self.treeView.set(childnode, "resource", concept.localName)
                 self.treeView.set(childnode, "resourcerole", os.path.basename(concept.role or ''))
                 self.treeView.set(childnode, "lang", concept.xmlLang)
         self.id += 1
         self.tag_has[modelObject.objectId()].append(childnode)
         if isRelation:
             self.tag_has[modelObject.toModelObject.objectId()].append(childnode)
         if concept not in visited:
             visited.add(concept)
             for modelRel in childRelationshipSet.fromModelObject(concept):
                 nestedRelationshipSet = childRelationshipSet
                 targetRole = modelRel.targetRole
                 if self.arcrole == XbrlConst.summationItem:
                     childPrefix = "({:0g}) ".format(modelRel.weight) # format without .0 on integer weights
                 elif targetRole is None or len(targetRole) == 0:
                     targetRole = relationshipSet.linkrole
                     childPrefix = ""
                 else:
                     nestedRelationshipSet = self.modelXbrl.relationshipSet(childRelationshipSet.arcrole, targetRole)
                     childPrefix = "(via targetRole) "
                 toConcept = modelRel.toModelObject
                 if toConcept in visited:
                     childPrefix += "(loop)"
                 labelrole = modelRel.preferredLabel
                 if not labelrole: labelrole = self.labelrole
                 n += 1 # child has opposite row style of parent
                 self.viewConcept(toConcept, modelRel, childPrefix, labelrole, childnode, n, nestedRelationshipSet, visited)
             visited.remove(concept)
     except AttributeError:
         return # bad object, don't try to display
Exemple #5
0
    def viewConcept(self, concept, modelObject, labelPrefix, preferredLabel,
                    parentnode, n, relationshipSet, visited):
        if concept is None:
            return
        try:
            isRelation = isinstance(modelObject,
                                    ModelDtsObject.ModelRelationship)
            isModelTable = False
            filingIndicatorCode = ""
            if isinstance(concept, ModelDtsObject.ModelConcept):
                text = labelPrefix + concept.label(
                    preferredLabel,
                    lang=self.lang,
                    linkroleHint=relationshipSet.linkrole)
                if (self.arcrole
                        in ("XBRL-dimensions", XbrlConst.hypercubeDimension)
                        and concept.isTypedDimension
                        and concept.typedDomainElement is not None):
                    text += " (typedDomain={0})".format(
                        concept.typedDomainElement.qname)
            elif isinstance(concept, ModelInstanceObject.ModelFact):
                if concept.concept is not None:
                    text = labelPrefix + concept.concept.label(
                        preferredLabel,
                        lang=self.lang,
                        linkroleHint=relationshipSet.linkrole)
                else:
                    text = str(concept.qname)
                if concept.contextID:
                    text += " [" + concept.contextID + "] = " + concept.effectiveValue
            elif self.arcrole == "Table-rendering":
                text = concept.localName
            elif isinstance(concept, ModelRenderingObject.ModelTable):
                text = (concept.genLabel(lang=self.lang, strip=True)
                        or concept.localName)
                isModelTable = True
            elif isinstance(concept, ModelDtsObject.ModelResource):
                if self.showReferences:
                    text = (concept.viewText() or concept.localName)
                else:
                    text = (Locale.rtlString(concept.textValue.strip(),
                                             lang=concept.xmlLang)
                            or concept.localName)
            else:  # just a resource
                text = concept.localName

            childnode = self.treeView.insert(parentnode,
                                             "end",
                                             modelObject.objectId(self.id),
                                             text=text,
                                             tags=("odd" if n
                                                   & 1 else "even", ))

            # Check if we need special rendering of this item
            for pluginXbrlMethod in pluginClassMethods(
                    "CntlrWinMain.Rendering.RenderConcept"):
                stopPlugin = pluginXbrlMethod(isModelTable, concept, text,
                                              self, self.modelXbrl, childnode)
                if stopPlugin == True:
                    break

            childRelationshipSet = relationshipSet
            if self.arcrole == XbrlConst.parentChild:  # extra columns
                if isRelation:
                    preferredLabel = modelObject.preferredLabel
                    if preferredLabel and preferredLabel.startswith(
                            "http://www.xbrl.org/2003/role/"):
                        preferredLabel = os.path.basename(preferredLabel)
                    self.treeView.set(childnode, "preferredLabel",
                                      preferredLabel)
                self.treeView.set(childnode, "type", concept.niceType)
                self.treeView.set(childnode, "references",
                                  viewReferences(concept))
            elif self.arcrole == XbrlConst.summationItem:
                if isRelation:
                    self.treeView.set(childnode, "weight",
                                      "{:+0g} ".format(modelObject.weight))
                self.treeView.set(childnode, "balance", concept.balance)
            elif self.arcrole == "XBRL-dimensions" and isRelation:  # extra columns
                relArcrole = modelObject.arcrole
                self.treeView.set(childnode, "arcrole",
                                  os.path.basename(relArcrole))
                if relArcrole in (XbrlConst.all, XbrlConst.notAll):
                    self.treeView.set(childnode, "contextElement",
                                      modelObject.contextElement)
                    self.treeView.set(childnode, "closed", modelObject.closed)
                elif relArcrole in (XbrlConst.dimensionDomain,
                                    XbrlConst.domainMember):
                    self.treeView.set(childnode, "usable", modelObject.usable)
                childRelationshipSet = self.modelXbrl.relationshipSet(
                    XbrlConst.consecutiveArcrole.get(relArcrole,
                                                     "XBRL-dimensions"),
                    modelObject.consecutiveLinkrole)
            elif self.arcrole == "Table-rendering":  # extra columns
                try:
                    header = concept.header(lang=self.lang,
                                            strip=True,
                                            evaluate=False)
                except AttributeError:
                    header = None  # could be a filter
                if isRelation and header is None:
                    header = "{0} {1}".format(
                        os.path.basename(modelObject.arcrole),
                        concept.xlinkLabel)
                self.treeView.set(childnode, "header", header)
                if concept.get("abstract") == "true":
                    self.treeView.set(childnode, "abstract",
                                      '\u2713')  # checkmark unicode character
                if concept.get("merge") == "true":
                    self.treeView.set(childnode, "merge",
                                      '\u2713')  # checkmark unicode character
                if isRelation:
                    self.treeView.set(childnode, "axis",
                                      modelObject.axisDisposition)
                    if isinstance(concept,
                                  (ModelEuAxisCoord, ModelRuleDefinitionNode)):
                        self.treeView.set(
                            childnode, "priItem",
                            concept.aspectValue(None, Aspect.CONCEPT))
                        self.treeView.set(
                            childnode, "dims", ' '.join(
                                ("{0},{1}".format(
                                    dim, concept.aspectValue(None, dim))
                                 for dim in (concept.aspectValue(
                                     None, Aspect.DIMENSIONS, inherit=False)
                                             or []))))
            elif self.isResourceArcrole:  # resource columns
                if isRelation:
                    self.treeView.set(childnode, "arcrole",
                                      os.path.basename(modelObject.arcrole))
                if isinstance(concept, ModelDtsObject.ModelResource):
                    self.treeView.set(childnode, "resource", concept.localName)
                    self.treeView.set(childnode, "resourcerole",
                                      os.path.basename(concept.role or ''))
                    self.treeView.set(childnode, "lang", concept.xmlLang)
            self.id += 1
            self.tag_has[modelObject.objectId()].append(childnode)
            if isRelation:
                self.tag_has[modelObject.toModelObject.objectId()].append(
                    childnode)
            if concept not in visited:
                visited.add(concept)
                for modelRel in childRelationshipSet.fromModelObject(concept):
                    nestedRelationshipSet = childRelationshipSet
                    targetRole = modelRel.targetRole
                    if self.arcrole == XbrlConst.summationItem:
                        childPrefix = "({:0g}) ".format(
                            modelRel.weight
                        )  # format without .0 on integer weights
                    elif targetRole is None or len(targetRole) == 0:
                        targetRole = relationshipSet.linkrole
                        childPrefix = ""
                    else:
                        nestedRelationshipSet = self.modelXbrl.relationshipSet(
                            childRelationshipSet.arcrole, targetRole)
                        childPrefix = "(via targetRole) "
                    toConcept = modelRel.toModelObject
                    if toConcept in visited:
                        childPrefix += "(loop)"
                    labelrole = modelRel.preferredLabel
                    if not labelrole or self.labelrole == conceptNameLabelRole:
                        labelrole = self.labelrole
                    n += 1  # child has opposite row style of parent
                    self.viewConcept(toConcept, modelRel, childPrefix,
                                     labelrole, childnode, n,
                                     nestedRelationshipSet, visited)
                visited.remove(concept)
        except AttributeError:
            return  # bad object, don't try to display