Ejemplo n.º 1
0
    def bodyCells(self, row, yParentStructuralNode, xStructuralNodes, zAspects,
                  yChildrenFirst):
        if yParentStructuralNode is not None:
            rendrCntx = getattr(self.modelXbrl, "rendrCntx",
                                None)  # none for EU 2010 tables
            dimDefaults = self.modelXbrl.qnameDimensionDefaults
            for yStructuralNode in yParentStructuralNode.childStructuralNodes:
                if yChildrenFirst:
                    row = self.bodyCells(row, yStructuralNode,
                                         xStructuralNodes, zAspects,
                                         yChildrenFirst)
                if not yStructuralNode.isAbstract:
                    yAspects = defaultdict(set)
                    for aspect in aspectModels[self.aspectModel]:
                        for ruleAspect in aspectRuleAspects.get(
                                aspect, (aspect, )):
                            if yStructuralNode.hasAspect(ruleAspect):
                                if ruleAspect == Aspect.DIMENSIONS:
                                    for dim in (yStructuralNode.aspectValue(
                                            Aspect.DIMENSIONS) or emptyList):
                                        yAspects[dim].add(yStructuralNode)
                                else:
                                    yAspects[ruleAspect].add(yStructuralNode)

                    gridSpacer(self.gridBody, self.dataFirstCol, row,
                               LEFTBORDER)
                    # data for columns of row
                    ignoreDimValidity = self.ignoreDimValidity.get()
                    for i, xStructuralNode in enumerate(xStructuralNodes):
                        xAspects = defaultdict(set)
                        for aspect in aspectModels[self.aspectModel]:
                            for ruleAspect in aspectRuleAspects.get(
                                    aspect, (aspect, )):
                                if xStructuralNode.hasAspect(ruleAspect):
                                    if ruleAspect == Aspect.DIMENSIONS:
                                        for dim in (
                                                xStructuralNode.aspectValue(
                                                    Aspect.DIMENSIONS)
                                                or emptyList):
                                            xAspects[dim].add(xStructuralNode)
                                    else:
                                        xAspects[ruleAspect].add(
                                            xStructuralNode)
                        cellAspectValues = {}
                        matchableAspects = set()
                        for aspect in _DICT_SET(xAspects.keys()) | _DICT_SET(
                                yAspects.keys()) | _DICT_SET(zAspects.keys()):
                            aspectValue = inheritedAspectValue(
                                self, aspect, xAspects, yAspects, zAspects,
                                xStructuralNode, yStructuralNode)
                            if dimDefaults.get(
                                    aspect
                            ) != aspectValue:  # don't include defaulted dimensions
                                cellAspectValues[aspect] = aspectValue
                            matchableAspects.add(
                                aspectModelAspect.get(aspect, aspect)
                            )  #filterable aspect from rule aspect
                        cellDefaultedDims = _DICT_SET(dimDefaults) - _DICT_SET(
                            cellAspectValues.keys())
                        priItemQname = cellAspectValues.get(Aspect.CONCEPT)

                        concept = self.modelXbrl.qnameConcepts.get(
                            priItemQname)
                        conceptNotAbstract = concept is None or not concept.isAbstract
                        from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                        value = None
                        objectId = None
                        justify = None
                        fp = FactPrototype(self, cellAspectValues)
                        if conceptNotAbstract:
                            # reduce set of matchable facts to those with pri item qname and have dimension aspects
                            facts = self.modelXbrl.factsByQname[
                                priItemQname] if priItemQname else self.modelXbrl.factsInInstance
                            for aspect in matchableAspects:  # trim down facts with explicit dimensions match or just present
                                if isinstance(aspect, QName):
                                    aspectValue = cellAspectValues.get(
                                        aspect, None)
                                    if isinstance(aspectValue,
                                                  ModelDimensionValue):
                                        if aspectValue.isExplicit:
                                            dimMemQname = aspectValue.memberQname  # match facts with this explicit value
                                        else:
                                            dimMemQname = None  # match facts that report this dimension
                                    elif isinstance(aspectValue, QName):
                                        dimMemQname = aspectValue  # match facts that have this explicit value
                                    else:
                                        dimMemQname = None  # match facts that report this dimension
                                    facts = facts & self.modelXbrl.factsByDimMemQname(
                                        aspect, dimMemQname)
                            for fact in facts:
                                if (all(
                                        aspectMatches(rendrCntx, fact, fp,
                                                      aspect)
                                        for aspect in matchableAspects)
                                        and all(
                                            fact.context.dimMemberQname(
                                                dim, includeDefaults=True) in (
                                                    dimDefaults[dim], None)
                                            for dim in cellDefaultedDims)):
                                    if yStructuralNode.hasValueExpression(
                                            xStructuralNode):
                                        value = yStructuralNode.evalValueExpression(
                                            fact, xStructuralNode)
                                    else:
                                        value = fact.effectiveValue
                                    objectId = fact.objectId()
                                    justify = "right" if fact.isNumeric else "left"
                                    break
                        if (conceptNotAbstract
                                and (value is not None or ignoreDimValidity
                                     or isFactDimensionallyValid(self, fp))):
                            if objectId is None:
                                objectId = "f{0}".format(
                                    len(self.factPrototypes))
                                self.factPrototypes.append(
                                    fp)  # for property views
                            gridCell(
                                self.gridBody,
                                self.dataFirstCol + i,
                                row,
                                value,
                                justify=justify,
                                width=
                                12,  # width is in characters, not screen units
                                objectId=objectId,
                                onClick=self.onClick)
                        else:
                            fp.clear()  # dereference
                            gridSpacer(self.gridBody, self.dataFirstCol + i,
                                       row, CENTERCELL)
                        gridSpacer(self.gridBody, self.dataFirstCol + i, row,
                                   RIGHTBORDER)
                        gridSpacer(self.gridBody, self.dataFirstCol + i, row,
                                   BOTTOMBORDER)
                    row += 1
                if not yChildrenFirst:
                    row = self.bodyCells(row, yStructuralNode,
                                         xStructuralNodes, zAspects,
                                         yChildrenFirst)
            return row
Ejemplo n.º 2
0
 def bodyCells(self, row, yParentStructuralNode, xStructuralNodes, zAspects, yChildrenFirst):
     if yParentStructuralNode is not None:
         rendrCntx = getattr(self.modelXbrl, "rendrCntx", None) # none for EU 2010 tables
         dimDefaults = self.modelXbrl.qnameDimensionDefaults
         for yStructuralNode in yParentStructuralNode.childStructuralNodes:
             if yChildrenFirst:
                 row = self.bodyCells(row, yStructuralNode, xStructuralNodes, zAspects, yChildrenFirst)
             if not yStructuralNode.isAbstract:
                 yAspects = defaultdict(set)
                 for aspect in aspectModels[self.aspectModel]:
                     for ruleAspect in aspectRuleAspects.get(aspect, (aspect,)):
                         if yStructuralNode.hasAspect(ruleAspect):
                             if ruleAspect == Aspect.DIMENSIONS:
                                 for dim in (yStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                     yAspects[dim].add(yStructuralNode)
                             else:
                                 yAspects[ruleAspect].add(yStructuralNode)
                     
                 gridSpacer(self.gridBody, self.dataFirstCol, row, LEFTBORDER)
                 # data for columns of row
                 ignoreDimValidity = self.ignoreDimValidity.get()
                 for i, xStructuralNode in enumerate(xStructuralNodes):
                     xAspects = defaultdict(set)
                     for aspect in aspectModels[self.aspectModel]:
                         for ruleAspect in aspectRuleAspects.get(aspect, (aspect,)):
                             if xStructuralNode.hasAspect(ruleAspect):
                                 if ruleAspect == Aspect.DIMENSIONS:
                                     for dim in (xStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                         xAspects[dim].add(xStructuralNode)
                                 else:
                                     xAspects[ruleAspect].add(xStructuralNode)
                     cellAspectValues = {}
                     matchableAspects = set()
                     for aspect in _DICT_SET(xAspects.keys()) | _DICT_SET(yAspects.keys()) | _DICT_SET(zAspects.keys()):
                         aspectValue = inheritedAspectValue(self, aspect, xAspects, yAspects, zAspects, xStructuralNode, yStructuralNode)
                         if dimDefaults.get(aspect) != aspectValue: # don't include defaulted dimensions
                             cellAspectValues[aspect] = aspectValue
                         matchableAspects.add(aspectModelAspect.get(aspect,aspect)) #filterable aspect from rule aspect
                     cellDefaultedDims = _DICT_SET(dimDefaults) - _DICT_SET(cellAspectValues.keys())
                     priItemQname = cellAspectValues.get(Aspect.CONCEPT)
                         
                     concept = self.modelXbrl.qnameConcepts.get(priItemQname)
                     conceptNotAbstract = concept is None or not concept.isAbstract
                     from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                     value = None
                     objectId = None
                     justify = None
                     fp = FactPrototype(self, cellAspectValues)
                     if conceptNotAbstract:
                         # reduce set of matchable facts to those with pri item qname and have dimension aspects
                         facts = self.modelXbrl.factsByQname[priItemQname] if priItemQname else self.modelXbrl.factsInInstance
                         for aspect in matchableAspects:  # trim down facts with explicit dimensions match or just present
                             if isinstance(aspect, QName):
                                 aspectValue = cellAspectValues.get(aspect, None)
                                 if isinstance(aspectValue, ModelDimensionValue):
                                     if aspectValue.isExplicit:
                                         dimMemQname = aspectValue.memberQname # match facts with this explicit value
                                     else:
                                         dimMemQname = None  # match facts that report this dimension
                                 elif isinstance(aspectValue, QName): 
                                     dimMemQname = aspectValue  # match facts that have this explicit value
                                 else:
                                     dimMemQname = None # match facts that report this dimension
                                 facts = facts & self.modelXbrl.factsByDimMemQname(aspect, dimMemQname)
                         for fact in facts:
                             if (all(aspectMatches(rendrCntx, fact, fp, aspect) 
                                     for aspect in matchableAspects) and
                                 all(fact.context.dimMemberQname(dim,includeDefaults=True) in (dimDefaults[dim], None)
                                     for dim in cellDefaultedDims)):
                                 if yStructuralNode.hasValueExpression(xStructuralNode):
                                     value = yStructuralNode.evalValueExpression(fact, xStructuralNode)
                                 else:
                                     value = fact.effectiveValue
                                 objectId = fact.objectId()
                                 justify = "right" if fact.isNumeric else "left"
                                 break
                     if (conceptNotAbstract and
                         (value is not None or ignoreDimValidity or isFactDimensionallyValid(self, fp))):
                         if objectId is None:
                             objectId = "f{0}".format(len(self.factPrototypes))
                             self.factPrototypes.append(fp)  # for property views
                         gridCell(self.gridBody, self.dataFirstCol + i, row, value, justify=justify, 
                                  width=12, # width is in characters, not screen units
                                  objectId=objectId, onClick=self.onClick)
                     else:
                         fp.clear()  # dereference
                         gridSpacer(self.gridBody, self.dataFirstCol + i, row, CENTERCELL)
                     gridSpacer(self.gridBody, self.dataFirstCol + i, row, RIGHTBORDER)
                     gridSpacer(self.gridBody, self.dataFirstCol + i, row, BOTTOMBORDER)
                 row += 1
             if not yChildrenFirst:
                 row = self.bodyCells(row, yStructuralNode, xStructuralNodes, zAspects, yChildrenFirst)
         return row
Ejemplo n.º 3
0
 def bodyCells(self, row, yParentStructuralNode, xStructuralNodes, zAspects, yChildrenFirst):
     if yParentStructuralNode is not None:
         rendrCntx = getattr(self.modelXbrl, "rendrCntx", None) # none for EU 2010 tables
         dimDefaults = self.modelXbrl.qnameDimensionDefaults
         for yStructuralNode in yParentStructuralNode.childStructuralNodes:
             if yChildrenFirst:
                 row = self.bodyCells(row, yStructuralNode, xStructuralNodes, zAspects, yChildrenFirst)
             if not yStructuralNode.isAbstract:
                 if self.type == XML:
                     self.xCells = etree.SubElement(self.yCells, tableModelQName("cells"),
                                                    attrib={"disposition": "x"})
                 yAspects = defaultdict(set)
                 for aspect in aspectModels[self.aspectModel]:
                     for ruleAspect in aspectRuleAspects.get(aspect, (aspect,)):
                         if yStructuralNode.hasAspect(ruleAspect):
                             if ruleAspect == Aspect.DIMENSIONS:
                                 for dim in (yStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                     yAspects[dim].add(yStructuralNode)
                             else:
                                 yAspects[ruleAspect].add(yStructuralNode)
                 # data for columns of rows
                 ignoreDimValidity = self.ignoreDimValidity.get()
                 for i, xStructuralNode in enumerate(xStructuralNodes):
                     xAspects = defaultdict(set)
                     for aspect in aspectModels[self.aspectModel]:
                         for ruleAspect in aspectRuleAspects.get(aspect, (aspect,)):
                             if xStructuralNode.hasAspect(ruleAspect):
                                 if ruleAspect == Aspect.DIMENSIONS:
                                     for dim in (xStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                         xAspects[dim].add(xStructuralNode)
                                 else:
                                     xAspects[ruleAspect].add(xStructuralNode)
                     cellAspectValues = {}
                     matchableAspects = set()
                     for aspect in _DICT_SET(xAspects.keys()) | _DICT_SET(yAspects.keys()) | _DICT_SET(zAspects.keys()):
                         aspectValue = inheritedAspectValue(self, aspect, xAspects, yAspects, zAspects, xStructuralNode, yStructuralNode)
                         if dimDefaults.get(aspect) != aspectValue: # don't include defaulted dimensions
                             cellAspectValues[aspect] = aspectValue
                         matchableAspects.add(aspectModelAspect.get(aspect,aspect)) #filterable aspect from rule aspect
                     cellDefaultedDims = _DICT_SET(dimDefaults) - _DICT_SET(cellAspectValues.keys())
                     priItemQname = cellAspectValues.get(Aspect.CONCEPT)
                         
                     concept = self.modelXbrl.qnameConcepts.get(priItemQname)
                     conceptNotAbstract = concept is None or not concept.isAbstract
                     from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                     value = None
                     objectId = None
                     justify = None
                     fp = FactPrototype(self, cellAspectValues)
                     if conceptNotAbstract:
                         # reduce set of matchable facts to those with pri item qname and have dimension aspects
                         facts = self.modelXbrl.factsByQname[priItemQname] if priItemQname else self.modelXbrl.factsInInstance
                         for aspect in matchableAspects:  # trim down facts with explicit dimensions match or just present
                             if isinstance(aspect, QName):
                                 aspectValue = cellAspectValues.get(aspect, None)
                                 if isinstance(aspectValue, ModelDimensionValue):
                                     if aspectValue.isExplicit:
                                         dimMemQname = aspectValue.memberQname # match facts with this explicit value
                                     else:
                                         dimMemQname = None  # match facts that report this dimension
                                 elif isinstance(aspectValue, QName): 
                                     dimMemQname = aspectValue  # match facts that have this explicit value
                                 else:
                                     dimMemQname = None # match facts that report this dimension
                                 facts = facts & self.modelXbrl.factsByDimMemQname(aspect, dimMemQname)
                         for fact in facts:
                             if (all(aspectMatches(rendrCntx, fact, fp, aspect) 
                                     for aspect in matchableAspects) and
                                 all(fact.context.dimMemberQname(dim,includeDefaults=True) in (dimDefaults[dim], None)
                                     for dim in cellDefaultedDims)):
                                 if yStructuralNode.hasValueExpression(xStructuralNode):
                                     value = yStructuralNode.evalValueExpression(fact, xStructuralNode)
                                 else:
                                     value = fact.effectiveValue
                                 justify = "right" if fact.isNumeric else "left"
                                 break
                     if conceptNotAbstract:
                         if value is not None or ignoreDimValidity or isFactDimensionallyValid(self, fp):
                             if self.type == HTML:
                                 etree.SubElement(self.rowElts[row - 1], 
                                                  "{http://www.w3.org/1999/xhtml}td",
                                                  attrib={"class":"cell",
                                                          "style":"text-align:{0};width:8em".format(justify)}
                                                  ).text = value or "\u00A0"
                             elif self.type == XML:
                                 if value is not None and fact is not None:
                                     self.xCells.append(etree.Comment("{0}: context {1}, value {2}, file {3}, line {4}"
                                                                      .format(fact.qname,
                                                                              fact.contextID,
                                                                              value,
                                                                              fact.modelDocument.basename, 
                                                                              fact.sourceline)))
 
                                 cellElt = etree.SubElement(self.xCells, tableModelQName("cell"))
                                 etree.SubElement(cellElt, tableModelQName("fact")
                                                  ).text = '#' + elementFragmentIdentifier(fact)
                         else:
                             if self.type == HTML:
                                 etree.SubElement(self.rowElts[row - 1], 
                                                  "{http://www.w3.org/1999/xhtml}td",
                                                  attrib={"class":"blockedCell",
                                                          "style":"text-align:{0};width:8em".format(justify)}
                                                  ).text = "\u00A0\u00A0"
                             elif self.type == XML:
                                 etree.SubElement(self.xCells, tableModelQName("cell"),
                                                  attrib={"blocked":"true"})
                     else: # concept is abstract
                         if self.type == HTML:
                             etree.SubElement(self.rowElts[row - 1], 
                                              "{http://www.w3.org/1999/xhtml}td",
                                              attrib={"class":"abstractCell",
                                                      "style":"text-align:{0};width:8em".format(justify)}
                                              ).text = "\u00A0\u00A0"
                         elif self.type == XML:
                             etree.SubElement(self.xCells, tableModelQName("cell"),
                                              attrib={"abstract":"true"})
                     fp.clear()  # dereference
                 row += 1
             if not yChildrenFirst:
                 row = self.bodyCells(row, yStructuralNode, xStructuralNodes, zAspects, yChildrenFirst)
     return row