Esempio n. 1
0
 def bodyCells(self, row, indent, tupleFacts, xFilters, zFilters):
     for modelTupleFact in tupleFacts:
         if modelTupleFact.concept == self.tupleConcept:
             for i, xColConcept in enumerate(xFilters):
                 fact = self.tupleDescendant(modelTupleFact, xColConcept)
                 if fact is not None:
                     value = fact.effectiveValue
                     objectId = fact.objectId()
                     justify = "right" if fact.isNumeric else "left"
                 else:
                     value = None
                     objectId = None
                 if value is not None:
                     gridCell(self.gridBody,
                              self.dataFirstCol + i,
                              row,
                              value,
                              justify=justify,
                              width=12,
                              objectId=objectId,
                              onClick=self.onClick)
                 else:
                     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
     return row
Esempio n. 2
0
 def bodyCells(self, row, yAxisParentObj, xFilters, zFilters, yChildrenFirst):
     dimDefaults = self.modelXbrl.qnameDimensionDefaults
     priItemQnameErrors = set()
     dimQnameErrors = set()
     memQnameErrors = set()
     for axisMbrRel in self.axisMbrRelSet.fromModelObject(yAxisParentObj):
         yAxisHdrObj = axisMbrRel.toModelObject
         if yChildrenFirst:
             row = self.bodyCells(row, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
         if yAxisHdrObj.abstract == "false":
             yAxisPriItemQname = inheritedPrimaryItemQname(self, yAxisHdrObj)
             yAxisExplicitDims = inheritedExplicitDims(self, yAxisHdrObj)
                 
             gridSpacer(self.gridBody, self.dataFirstCol, row, LEFTBORDER)
             # data for columns of row
             ignoreDimValidity = self.ignoreDimValidity.get()
             zPriItemQname = None
             zDims = set()
             for zIndex in self.zFilterIndex:
                 zFilter = zFilters[zIndex]
                 if zFilter[0]: zPriItemQname = zFilter[0] # inherit pri item
                 zDims |= zFilter[1] # or in z-dims
             for i, colFilter in enumerate(xFilters):
                 colPriItemQname = colFilter[0] # y axis pri item
                 if not colPriItemQname: colPriItemQname = yAxisPriItemQname # y axis
                 if not colPriItemQname: colPriItemQname = zPriItemQname # z axis
                 fp = FactPrototype(self,
                                    colPriItemQname,
                                    yAxisExplicitDims | colFilter[1] | zDims)
                 from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                 value = None
                 objectId = None
                 justify = None
                 for fact in self.modelXbrl.facts:
                     if fact.qname == fp.qname:
                         factDimMem = fact.context.dimMemberQname
                         defaultedDims = _DICT_SET(dimDefaults.keys()) - fp.dimKeys
                         if (all(factDimMem(dim,includeDefaults=True) == mem 
                                 for dim, mem in fp.dims) and
                             all(factDimMem(dim,includeDefaults=True) in (dimDefaults[dim], None)
                                 for dim in defaultedDims)):
                             value = fact.effectiveValue
                             objectId = fact.objectId()
                             justify = "right" if fact.isNumeric else "left"
                             break
                 if 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:
                     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, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
     return row
Esempio n. 3
0
    def bodyCells(self, row, indent, yAxisParentObj, xFilters, zFilters, yChildrenFirst):
        for axisMbrRel in self.axisMbrRelSet.fromModelObject(yAxisParentObj):
            yAxisHdrObj = axisMbrRel.toModelObject
            if yChildrenFirst:
                row = self.bodyCells(row, indent + 20, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
            if yAxisHdrObj.abstract == "false":
                yAxisPriItemQname = self.inheritedPrimaryItemQname(yAxisHdrObj)
                yAxisExplicitDims = self.inheritedExplicitDims(yAxisHdrObj)

                # data for columns of row
                ignoreDimValidity = self.ignoreDimValidity.get()
                zFilter = zFilters[self.zFilterIndex]
                for i, colFilter in enumerate(xFilters):
                    colPriItemQname = colFilter[0]  # y axis pri item
                    if not colPriItemQname:
                        colPriItemQname = yAxisPriItemQname  # y axis
                    if not colPriItemQname:
                        colPriItemQname = zFilter[0]  # z axis
                    fp = FactPrototype(self, colPriItemQname, yAxisExplicitDims | colFilter[1] | zFilter[1])
                    from arelle.ValidateXbrlDimensions import isFactDimensionallyValid

                    value = None
                    objectId = None
                    justify = None
                    for fact in self.modelXbrl.facts:
                        if fact.qname == fp.qname and all(
                            fact.context.dimMemberQname(dim, includeDefaults=True) == mem for dim, mem in fp.dims
                        ):
                            value = fact.effectiveValue
                            objectId = fact.objectId()
                            justify = "right" if fact.isNumeric else "left"
                            break
                    if value is not None or ignoreDimValidity or isFactDimensionallyValid(self, fp):
                        gridCell(
                            self.gridBody,
                            self.dataFirstCol + i,
                            row,
                            value,
                            justify=justify,
                            width=12,
                            objectId=objectId,
                            onClick=self.onClick,
                        )
                    else:
                        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, indent + 20, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
        return row
Esempio n. 4
0
def dialogRssWatchDBextender(dialog, frame, row, options, cntlr, openFileImage, openDatabaseImage):
    from tkinter import PhotoImage, N, S, E, W
    from tkinter.simpledialog import askstring
    from arelle.CntlrWinTooltip import ToolTip
    from arelle.UiUtil import gridCell, label
    try:
        from tkinter.ttk import Button
    except ImportError:
        from ttk import Button
        
    def enterConnectionString():
        from arelle.DialogUserPassword import askDatabase
        # (user, password, host, port, database)
        db = askDatabase(cntlr.parent, dialog.cellDBconnection.value.split(',') if dialog.cellDBconnection.value else None)
        if db:
            dbConnectionString = ','.join(db)
            dialog.options["xbrlDBconnection"] = dbConnectionString 
            dialog.cellDBconnection.setValue(dbConnectionString)
        else:  # deleted
            dialog.options.pop("xbrlDBconnection", "")  # remove entry
    label(frame, 1, row, "DB Connection:")
    dialog.cellDBconnection = gridCell(frame,2, row, options.get("xbrlDBconnection",""))
    ToolTip(dialog.cellDBconnection, text=_("Enter an XBRL Database (Postgres) connection string.  "
                                           "E.g., host,port,user,password,db[,timeout].  "), wraplength=240)
    enterDBconnectionButton = Button(frame, image=openDatabaseImage, width=12, command=enterConnectionString)
    enterDBconnectionButton.grid(row=row, column=3, sticky=W)
Esempio n. 5
0
def sphinxDialogRssWatchFileChoices(dialog, frame, row, options, cntlr, openFileImage, openDatabaseImage):
    from tkinter import PhotoImage, N, S, E, W
    try:
        from tkinter.ttk import Button
    except ImportError:
        from ttk import Button
    from arelle.CntlrWinTooltip import ToolTip
    from arelle.UiUtil import gridCell, label
    # add sphinx formulas to RSS dialog
    def chooseSphinxFiles():
        sphinxFilesList = cntlr.uiFileDialog("open",
                multiple=True,  # expect multiple sphinx files
                title=_("arelle - Select sphinx rules file"),
                initialdir=cntlr.config.setdefault("rssWatchSphinxRulesFilesDir","."),
                filetypes=[(_("Sphinx files .xsr"), "*.xsr"), (_("Sphinx archives .xrb"), "*.xrb")],
                defaultextension=".xsr")
        if sphinxFilesList:
            dialog.options["rssWatchSphinxRulesFilesDir"] = os.path.dirname(sphinxFilesList[0])
            sphinxFilesPipeSeparated = '|'.join(sphinxFilesList)
            dialog.options["sphinxRulesFiles"] = sphinxFilesPipeSeparated
            dialog.cellSphinxFiles.setValue(sphinxFilesPipeSeparated)
        else:  # deleted
            dialog.options.pop("sphinxRulesFiles", "")  # remove entry
    label(frame, 1, row, "Sphinx rules:")
    dialog.cellSphinxFiles = gridCell(frame,2, row, options.get("sphinxRulesFiles",""))
    ToolTip(dialog.cellSphinxFiles, text=_("Select a sphinx rules (file(s) or archive(s)) to to evaluate each filing.  "
                                           "The results are recorded in the log file.  "), wraplength=240)
    chooseFormulaFileButton = Button(frame, image=openFileImage, width=12, command=chooseSphinxFiles)
    chooseFormulaFileButton.grid(row=row, column=3, sticky=W)
Esempio n. 6
0
def sphinxDialogRssWatchFileChoices(dialog, frame, row, options, cntlr, openFileImage, openDatabaseImage, *args, **kwargs):
    from tkinter import PhotoImage, N, S, E, W
    try:
        from tkinter.ttk import Button
    except ImportError:
        from ttk import Button
    from arelle.CntlrWinTooltip import ToolTip
    from arelle.UiUtil import gridCell, label
    # add sphinx formulas to RSS dialog
    def chooseSphinxFiles():
        sphinxFilesList = cntlr.uiFileDialog("open",
                multiple=True,  # expect multiple sphinx files
                title=_("arelle - Select sphinx rules file"),
                initialdir=cntlr.config.setdefault("rssWatchSphinxRulesFilesDir","."),
                filetypes=[(_("Sphinx files .xsr"), "*.xsr"), (_("Sphinx archives .xrb"), "*.xrb")],
                defaultextension=".xsr")
        if sphinxFilesList:
            dialog.options["rssWatchSphinxRulesFilesDir"] = os.path.dirname(sphinxFilesList[0])
            sphinxFilesPipeSeparated = '|'.join(sphinxFilesList)
            dialog.options["sphinxRulesFiles"] = sphinxFilesPipeSeparated
            dialog.cellSphinxFiles.setValue(sphinxFilesPipeSeparated)
        else:  # deleted
            dialog.options.pop("sphinxRulesFiles", "")  # remove entry
    label(frame, 1, row, "Sphinx rules:")
    dialog.cellSphinxFiles = gridCell(frame,2, row, options.get("sphinxRulesFiles",""))
    ToolTip(dialog.cellSphinxFiles, text=_("Select a sphinx rules (file(s) or archive(s)) to to evaluate each filing.  "
                                           "The results are recorded in the log file.  "), wraplength=240)
    chooseFormulaFileButton = Button(frame, image=openFileImage, width=12, command=chooseSphinxFiles)
    chooseFormulaFileButton.grid(row=row, column=3, sticky=W)
Esempio n. 7
0
 def bodyCells(self, row, indent, yAxisParentObj, xFilters, zFilters, yChildrenFirst):
     for axisMbrRel in self.axisMbrRelSet.fromModelObject(yAxisParentObj):
         yAxisHdrObj = axisMbrRel.toModelObject
         if yChildrenFirst:
             row = self.bodyCells(row, indent + 20, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
         if yAxisHdrObj.abstract == "false":
             yAxisPriItemQname = self.inheritedPrimaryItemQname(yAxisHdrObj)
             yAxisExplicitDims = self.inheritedExplicitDims(yAxisHdrObj)
                 
             # data for columns of row
             ignoreDimValidity = self.ignoreDimValidity.get()
             zFilter = zFilters[self.zFilterIndex]
             for i, colFilter in enumerate(xFilters):
                 colPriItemQname = colFilter[0] # y axis pri item
                 if not colPriItemQname: colPriItemQname = yAxisPriItemQname # y axis
                 if not colPriItemQname: colPriItemQname = zFilter[0] # z axis
                 fp = FactPrototype(self,
                                    colPriItemQname,
                                    yAxisExplicitDims | colFilter[1] | zFilter[1])
                 from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                 value = None
                 objectId = None
                 justify = None
                 for fact in self.modelXbrl.facts:
                     if (fact.qname == fp.qname and
                         all(fact.context.dimMemberQname(dim,includeDefaults=True) == mem 
                             for dim, mem in fp.dims)):
                             value = fact.effectiveValue
                             objectId = fact.objectId()
                             justify = "right" if fact.isNumeric else "left"
                             break
                 if value is not None or ignoreDimValidity or isFactDimensionallyValid(self, fp):
                     gridCell(self.gridBody, self.dataFirstCol + i, row, value, justify=justify, width=12,
                              objectId=objectId, onClick=self.onClick)
                 else:
                     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, indent + 20, yAxisHdrObj, xFilters, zFilters, yChildrenFirst)
     return row
Esempio n. 8
0
 def bodyCells(self, row, indent, tupleFacts, xFilters, zFilters):
     for modelTupleFact in tupleFacts:
         if modelTupleFact.concept == self.tupleConcept:
             for i, xColConcept in enumerate(xFilters):
                 fact = self.tupleDescendant(modelTupleFact, xColConcept)
                 if fact:
                     value = fact.effectiveValue
                     objectId = fact.objectId()
                     justify = "right" if fact.isNumeric else "left"
                 else:
                     value = None
                     objectId = None
                 if value is not None:
                     gridCell(self.gridBody, self.dataFirstCol + i, row, value, justify=justify, width=12,
                              objectId=objectId, onClick=self.onClick)
                 else:
                     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
     return row
Esempio n. 9
0
    def __init__(self, mainWin, options):
        self.mainWin = mainWin
        parent = mainWin.parent
        super(DialogNewFactItemOptions, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("New Fact Item Options"))
        
        frame = Frame(self)

        label(frame, 1, 1, "Entity scheme:")
        self.cellEntityIdentScheme = gridCell(frame, 2, 1, getattr(options,"entityIdentScheme",""), width=50)
        ToolTip(self.cellEntityIdentScheme, text=_("Enter the scheme for the context entity identifier"), wraplength=240)
        label(frame, 1, 2, "Entity identifier:")
        self.cellEntityIdentValue = gridCell(frame, 2, 2, getattr(options,"entityIdentValue",""))
        ToolTip(self.cellEntityIdentValue, text=_("Enter the entity identifier value (e.g., stock ticker)"), wraplength=240)
        label(frame, 1, 3, "Start date:")
        startDate = getattr(options,"startDate",None)
        self.cellStartDate = gridCell(frame, 2, 3, XmlUtil.dateunionValue(startDate) if startDate else "")
        ToolTip(self.cellStartDate, text=_("Enter the start date for the report period (e.g., 2010-01-01)"), wraplength=240)
        label(frame, 1, 4, "End date:")
        endDate = getattr(options,"endDate",None)
        self.cellEndDate = gridCell(frame, 2, 4, XmlUtil.dateunionValue(endDate, subtractOneDay=True) if endDate else "")
        ToolTip(self.cellEndDate, text=_("Enter the end date for the report period (e.g., 2010-12-31)"), wraplength=240)
        label(frame, 1, 5, "Monetary unit:")
        self.cellMonetaryUnit = gridCombobox(frame, 2, 5, getattr(options,"monetaryUnit",""), values=monetaryUnits)
        ToolTip(self.cellMonetaryUnit, text=_("Select a monetary unit (e.g., EUR)"), wraplength=240)
        label(frame, 1, 6, "Monetary decimals:")
        self.cellMonetaryDecimals = gridCell(frame, 2, 6, getattr(options,"monetaryDecimals","2"))
        ToolTip(self.cellMonetaryDecimals, text=_("Enter decimals for monetary items"), wraplength=240)
        label(frame, 1, 7, "Non-monetary decimals:")
        self.cellNonMonetaryDecimals = gridCell(frame, 2, 7, getattr(options,"nonMonetaryDecimals","0"))
        ToolTip(self.cellNonMonetaryDecimals, text=_("Enter decimals for non-monetary items (e.g., stock shares)"), wraplength=240)

        cancelButton = Button(frame, text=_("Cancel"), width=8, command=self.close)
        ToolTip(cancelButton, text=_("Cancel operation, discarding changes and entries"))
        okButton = Button(frame, text=_("OK"), width=8, command=self.ok)
        ToolTip(okButton, text=_("Accept the options as entered above"))
        cancelButton.grid(row=8, column=1, columnspan=3, sticky=E, pady=3, padx=3)
        okButton.grid(row=8, column=1, columnspan=3, sticky=E, pady=3, padx=86)
        
        frame.grid(row=0, column=0, sticky=(N,S,E,W))
        frame.columnconfigure(2, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
        
        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)
        
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
Esempio n. 10
0
def xbrlDBdialogRssWatchDBconnection(dialog, frame, row, options, cntlr,
                                     openFileImage, openDatabaseImage):
    from tkinter import PhotoImage, N, S, E, W
    try:
        from tkinter.ttk import Button
        from tkinter.simpledialog import askstring
    except ImportError:
        from ttk import Button
    from arelle.CntlrWinTooltip import ToolTip
    from arelle.UiUtil import gridCell, label

    # add sphinx formulas to RSS dialog
    def enterConnectionString():
        from arelle.DialogUserPassword import askDatabase
        # (user, password, host, port, database)
        db = askDatabase(
            cntlr.parent,
            dialog.cellDBconnection.value.split(',')
            if dialog.cellDBconnection.value else None)
        if db:
            dbConnectionString = ','.join(db)
            dialog.options["xbrlDBconnection"] = dbConnectionString
            dialog.cellDBconnection.setValue(dbConnectionString)
        else:  # deleted
            dialog.options.pop("xbrlDBconnection", "")  # remove entry

    label(frame, 1, row, "DB Connection:")
    dialog.cellDBconnection = gridCell(frame, 2, row,
                                       options.get("xbrlDBconnection", ""))
    ToolTip(dialog.cellDBconnection,
            text=_("Enter an XBRL Database (Postgres) connection string.  "
                   "E.g., pg://dbuser:dbpassword@dbhost:port.  "),
            wraplength=240)
    enterDBconnectionButton = Button(frame,
                                     image=openDatabaseImage,
                                     width=12,
                                     command=enterConnectionString)
    enterDBconnectionButton.grid(row=row, column=3, sticky=W)
Esempio n. 11
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
Esempio n. 12
0
    def __init__(self, mainWin, options):
        parent = mainWin.parent
        self.modelManager = mainWin.modelManager
        super(DialogFormulaParameters, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)",
                                  parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("Formula Parameters and Trace Options"))

        frame = Frame(self)
        '''
        dialogFrame = Frame(frame, width=500)
        dialogFrame.columnconfigure(0, weight=1)
        dialogFrame.rowconfigure(0, weight=1)
        dialogFrame.grid(row=0, column=0, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
        '''

        # mainWin.showStatus(_("loading formula options and parameters"))

        # load grid
        gridHdr(frame, 1, 0, "Parameters", columnspan=3)
        gridHdr(frame, 1, 1, "QName")
        gridHdr(frame, 2, 1, "Type")
        gridHdr(frame, 3, 1, "Value")

        self.gridCells = []
        y = 2
        dataTypes = ("xs:string", "xs:integer", "xs:decimal", "xs:date",
                     "xs:datetime", "xs:QName")
        for parameter in options["parameterValues"].items():
            paramQname, paramTypeValue = parameter
            if isinstance(paramTypeValue, (tuple, list)):
                paramType, paramValue = paramTypeValue  # similar to modelTestcaseObject, where values() are (type,value)
            else:
                paramType = None
                paramValue = paramTypeValue
            self.gridCells.append((gridCell(frame, 1, y, paramQname),
                                   gridCombobox(frame,
                                                2,
                                                y,
                                                paramType,
                                                values=dataTypes),
                                   gridCell(frame, 3, y, paramValue)))
            y += 1
        # extra entry for new cells
        for i in range(5):
            self.gridCells.append(
                (gridCell(frame, 1,
                          y), gridCombobox(frame, 2, y, values=dataTypes),
                 gridCell(frame, 3, y)))
            y += 1
        y += 1

        # checkbox entries
        label(frame, 1, y, "Parameter Trace:")
        label(frame, 1, y + 3, "API Calls Trace:")
        label(frame, 1, y + 8, "Testcase Results:")
        label(frame, 2, y, "Variable Set Trace:")
        label(frame, 3, y, "Variables Trace:")
        self.checkboxes = (
            checkbox(frame, 1, y + 1, "Expression Result",
                     "traceParameterExpressionResult"),
            checkbox(frame, 1, y + 2, "Input Value",
                     "traceParameterInputValue"),
            checkbox(frame, 1, y + 4, "Expression Source",
                     "traceCallExpressionSource"),
            checkbox(frame, 1, y + 5, "Expression Code",
                     "traceCallExpressionCode"),
            checkbox(frame, 1, y + 6, "Expression Evaluation",
                     "traceCallExpressionEvaluation"),
            checkbox(frame, 1, y + 7, "Expression Result",
                     "traceCallExpressionResult"),
            checkbox(frame, 1, y + 9, "Capture Warnings",
                     "testcaseResultsCaptureWarnings"),
            checkbox(frame, 2, y + 1, "Expression Source",
                     "traceVariableSetExpressionSource"),
            checkbox(frame, 2, y + 2, "Expression Code",
                     "traceVariableSetExpressionCode"),
            checkbox(frame, 2, y + 3, "Expression Evaluation",
                     "traceVariableSetExpressionEvaluation"),
            checkbox(frame, 2, y + 4, "Expression Result",
                     "traceVariableSetExpressionResult"),
            checkbox(frame, 2, y + 5, "Assertion Result Counts",
                     "traceAssertionResultCounts"),
            checkbox(frame, 2, y + 6, "Assertion Satisfied [info]",
                     "traceSatisfiedAssertions"),
            checkbox(frame, 2, y + 7, "Assertion Unsatisfied [error]",
                     "errorUnsatisfiedAssertions"),
            checkbox(frame, 2, y + 8, "Assertion Unsatisfied [info]",
                     "traceUnsatisfiedAssertions"),
            checkbox(frame, 2, y + 9, "Formula Rules", "traceFormulaRules"),
            checkbox(frame, 2, y + 10, "Evaluation Timing",
                     "timeVariableSetEvaluation"),
            checkbox(frame, 3, y + 1, "Variable Dependencies",
                     "traceVariablesDependencies"),
            checkbox(frame, 3, y + 2, "Variables Order",
                     "traceVariablesOrder"),
            checkbox(frame, 3, y + 3, "Expression Source",
                     "traceVariableExpressionSource"),
            checkbox(frame, 3, y + 4, "Expression Code",
                     "traceVariableExpressionCode"),
            checkbox(frame, 3, y + 5, "Expression Evaluation",
                     "traceVariableExpressionEvaluation"),
            checkbox(frame, 3, y + 6, "Expression Result",
                     "traceVariableExpressionResult"),
            checkbox(frame, 3, y + 7, "Filter Winnowing",
                     "traceVariableFilterWinnowing"),
            checkbox(frame, 3, y + 8, "Filters Result",
                     "traceVariableFiltersResult")

            # Note: if adding to this list keep ModelFormulaObject.FormulaOptions in sync
        )
        y += 11

        mainWin.showStatus(None)

        label(frame, 1, y, "IDs:")
        self.idsEntry = gridCell(frame, 1, y, options.get("runIDs"))
        self.idsEntry.grid(columnspan=2, padx=30)
        _w = 8 if self.modelManager.cntlr.isMac else 12
        okButton = Button(frame, text=_("OK"), width=_w, command=self.ok)
        cancelButton = Button(frame,
                              text=_("Cancel"),
                              width=_w,
                              command=self.close)
        okButton.grid(row=y, column=3, sticky=W, pady=3)
        cancelButton.grid(row=y, column=3, sticky=E, pady=3, padx=3)

        frame.grid(row=0, column=0, sticky=(N, S, E, W))
        frame.columnconfigure(1, weight=3)
        frame.columnconfigure(2, weight=1)
        frame.columnconfigure(3, weight=3)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX + 50, dialogY + 100))

        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)

        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
Esempio n. 13
0
    def __init__(self, mainWin, options):
        parent = mainWin.parent
        super(DialogFind, self).__init__(parent)
        self.parent = parent
        self.modelManager = mainWin.modelManager
        self.modelXbrl = None  # set when Find pressed, this blocks next prematurely
        if options is None: options = newFindOptions
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)",
                                  parent.geometry())
        dialogW = int(parentGeometry.group(1))
        dialogH = int(parentGeometry.group(2))
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("Find"))

        self.objsList = []  # next may be tried before anything is found

        frame = Frame(self)

        # load grid
        findLabel = gridHdr(frame, 1, 0, "Find:", anchor="w")
        findLabel.grid(padx=8)
        self.cbExpr = gridCombobox(frame,
                                   1,
                                   1,
                                   values=options["priorExpressions"])
        self.cbExpr.grid(columnspan=3, padx=8)
        ToolTip(
            self.cbExpr,
            text=
            _("Enter expression to find, or select from combo box drop down history list."
              ),
            wraplength=240)

        y = 2

        # checkbox entries
        label(frame, 1, y, "Direction:")
        label(frame, 1, y + 3, "Match:")
        scopeLabel = label(frame, 2, y, "Scope:")
        ToolTip(scopeLabel,
                text=_("Scope for an XBRL document (instance or DTS).  "
                       "For an RSS Feed, all properties are matched.  "),
                wraplength=240)
        rbUp = radiobutton(frame, 1, y + 1, "Up", "up", "direction")
        ToolTip(rbUp,
                text=_("Find/Next up (on screen) from last to first match."),
                wraplength=240)
        rbDn = radiobutton(frame, 1, y + 2, "Down", "down", "direction",
                           rbUp.valueVar)
        ToolTip(rbDn,
                text=_("Find/Next down (on screen) from first to last match."),
                wraplength=240)
        rbText = radiobutton(frame, 1, y + 4, "Text (ignore case)", "text",
                             "exprType")
        ToolTip(
            rbText,
            text=_(
                "Expression is a set of characters to match, ignoring case.  "
                "The match may occur anywhere within the scope. "),
            wraplength=360)
        rbRegex = radiobutton(frame, 1, y + 5, "Regular expression", "regex",
                              "exprType", rbText.valueVar)
        ToolTip(
            rbRegex,
            text=
            _('A regular expression to match, anywhere in the scope, ignoring case.  '
              'For example, "cash" would match cash anywhere in a string (like cash on hand), '
              'whereas "^cash$" would match a full string to only contain cash. '
              'Use regular expression metacharacters, e.g., "." for any single character, '
              '".*" for any number of wild characters, .{3} for exactly 3 wild characters. '
              ),
            wraplength=360)
        rbXPath = radiobutton(frame, 1, y + 6, "XPath 2 expression", "xpath",
                              "exprType", rbText.valueVar)
        ToolTip(
            rbXPath,
            text=
            _('An XPath 2 expression, where the context element, ".", is a candidate concept QName, if any concept scope is checked, '
              'and a candidate fact item, if any fact scope is checked.  The XPath 2 functions do not need an "fn:" prefix (but it is defined).  '
              'The XBRL Functions Registry functions do require an "xfi:" prefix.  Constructors require an "xs:" prefix.  '
              'The expression is considered "matched" for the candidate concept QNames or fact items where the effective boolean value of the expression is "true()".  '
              ),
            wraplength=360)
        self.optionControls = (
            rbUp,
            rbDn,
            rbText,
            rbRegex,
            rbXPath,
            #checkbox(frame, 2, y + 1, "All", "all"),
            checkbox(frame, 2, y + 1, "Concept label", "conceptLabel"),
            checkbox(frame, 2, y + 2, "   name", "conceptName"),
            checkbox(frame, 2, y + 3, "   type", "conceptType"),
            checkbox(frame, 2, y + 4, "   subs group", "conceptSubs"),
            checkbox(frame, 2, y + 5, "   period type", "conceptPer"),
            checkbox(frame, 2, y + 6, "   balance", "conceptBal"),
            checkbox(frame, 3, y + 1, "Fact label", "factLabel"),
            checkbox(frame, 3, y + 2, "   name", "factName"),
            checkbox(frame, 3, y + 3, "   value", "factValue"),
            checkbox(frame, 3, y + 4, "   context", "factCntx"),
            checkbox(frame, 3, y + 5, "   unit", "factUnit"),
            checkbox(frame, 3, y + 6, "Messages", "messagesLog"),

            # Note: if adding to this list keep Finder.FindOptions in sync
        )
        y += 7
        resultLabel = gridHdr(frame, 1, y, "Result:", anchor="w")
        resultLabel.grid(padx=8)
        self.resultText = gridCell(frame, 1, y + 1)
        self.resultText.grid(columnspan=3, padx=8)
        self.resultText.config(state="readonly")
        y += 2

        mainWin.showStatus(None)

        buttonFrame = Frame(frame)
        buttonFrame.grid(columnspan=4, sticky=E, padx=8)
        findButton = Button(buttonFrame,
                            text=_("Find"),
                            width=12,
                            command=self.find)
        ToolTip(
            findButton,
            text=
            _('Compile (if regular expression or XPath 2), and find first match (if down direction) or last match (if up direction).  '
              ),
            wraplength=240)
        nextButton = Button(buttonFrame,
                            text=_("Next"),
                            width=12,
                            command=self.next)
        ToolTip(
            nextButton,
            text=_(
                'Advance to the next matched object (in selected direction).  '
            ),
            wraplength=240)
        closeButton = Button(buttonFrame,
                             text=_("Close"),
                             width=12,
                             command=self.close)
        ToolTip(closeButton,
                text=_('Close the find dialog.  '),
                wraplength=240)
        findButton.grid(row=1, column=1, pady=3)
        nextButton.grid(row=1, column=2, pady=3)
        closeButton.grid(row=1, column=3, padx=3)

        frame.grid(row=0, column=0, sticky=(N, S, E, W))
        frame.columnconfigure(1, weight=1)
        frame.columnconfigure(2, weight=1)
        frame.columnconfigure(3, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        if self.options["geometry"]:
            self.geometry(self.options["geometry"])
        else:
            self.geometry("+{0}+{1}".format(dialogX + 50, dialogY + 100))

        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)

        self.protocol("WM_DELETE_WINDOW", self.close)

        # make this dialog non-modal
        self.focus_set()
Esempio n. 14
0
    def __init__(self, mainWin, options):
        self.mainWin = mainWin
        parent = mainWin.parent
        super(DialogRssWatch, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("RSS Feed Processing Control"))
        
        frame = Frame(self)

        # checkbox entries
        label(frame, 1, 1, "RSS Feed:")
        feedSources = sorted(rssFeeds.keys())
        self.cellFeed = gridCombobox(frame, 2, 1, options.get("feedSource",""), values=feedSources)
        self.cellFeed.grid(pady=2)
        ToolTip(self.cellFeed, text=_("Select an RSS feed to process for item matching, formulas, and validations as selected below"), wraplength=240)
        label(frame, 1, 2, "Match fact text:")
        self.cellMatchText = gridCell(frame, 2, 2, options.get("matchTextExpr",""))
        ToolTip(self.cellMatchText, text=_("Enter a regular expression to be matched to the text of each filing instance fact item. "
                                           "Regular expressions may contain patterns to detect, such as ab.?c, for any single character between b and c, or ab.*c for any number of characters between b and c."), wraplength=240)
        label(frame, 1, 3, "Formula file:")
        self.cellFormulaFile = gridCell(frame,2, 3, options.get("formulaFileUri",""))
        ToolTip(self.cellFormulaFile, text=_("Select a formula linkbase to to evaluate each filing.  "
                                             "The formula linkbase may contain one or more assertions, the results of which is recorded in the log file.  "
                                             "If unsuccessful assertion alerts are selected and an e-mail address provided, the recipient will be notified of filings with assertions that do not pass."), wraplength=240)
        openFileImage = PhotoImage(file=os.path.join(mainWin.imagesDir, "toolbarOpenFile.gif"))
        chooseFormulaFileButton = Button(frame, image=openFileImage, width=12, command=self.chooseFormulaFile)
        chooseFormulaFileButton.grid(row=3, column=3, sticky=W)
        label(frame, 1, 4, "Log file:")
        self.cellLogFile = gridCell(frame,2, 4, options.get("logFileUri",""))
        ToolTip(self.cellLogFile, text=_("Select a log file in which to save an activity log, including validation results, matched item text, and formula results.\n\n "
                                         "Two files are produced, (1) .txt with the log messages, and (2) .csv with the RSS feed items and status.  "), wraplength=240)
        chooseLogFileButton = Button(frame, image=openFileImage, width=12, command=self.chooseLogFile)
        chooseLogFileButton.grid(row=4, column=3, sticky=W)
        label(frame, 1, 5, "E-mail alerts to:")
        self.cellEmailAddress = gridCell(frame,2, 5, options.get("emailAddress",""))
        ToolTip(self.cellEmailAddress, text=_("Specify e-mail recipient(s) for alerts per below."), wraplength=240)
        label(frame, 1, 6, "Latest pub date:")
        pubdate = getattr(options,"latestPubDate",None)
        self.cellLatestPubDate = gridCell(frame,2, 6, str(pubdate) if pubdate else "")
        ToolTip(self.cellLatestPubDate, text=_("Specify pub dateTime of last processed submission.  Next item to examine will be after this dateTime."), wraplength=240)
        clearImage = PhotoImage(file=os.path.join(mainWin.imagesDir, "toolbarDelete.gif"))
        clearPubDateButton = Button(frame, image=clearImage, width=12, command=self.clearPubDate)
        clearPubDateButton.grid(row=6, column=3, sticky=W)
        ToolTip(clearPubDateButton, text=_("Clear pub dateTime so that next cycle processes all entries in RSS feed."), wraplength=240)
        label(frame, 2, 7, "Validate:")
        label(frame, 2, 12, "Alert on:")
        self.checkboxes = (
           checkbox(frame, 2, 8, 
                    "XBRL 2.1 and Dimensions rules", 
                    "validateXbrlRules"),
           checkbox(frame, 2, 9, 
                    "Selected disclosure system rules", 
                    "validateDisclosureSystemRules"),
           checkbox(frame, 2, 10,
                    "Calculation linkbase roll-up", 
                    "validateCalcLinkbase"),
           checkbox(frame, 2, 11,
                    "Formula assertions", 
                    "validateFormulaAssertions"),
           checkbox(frame, 2, 13, 
                    "Facts with matching text", 
                    "alertMatchedFactText"),
           checkbox(frame, 2, 14,
                    "Unsuccessful formula assertions", 
                    "alertAssertionUnsuccessful"),
           checkbox(frame, 2, 15, 
                    "Validation errors", 
                    "alertValiditionError"),

        
           # Note: if adding to this list keep ModelFormulaObject.FormulaOptions in sync
        
           )
        
        mainWin.showStatus(None)

        cancelButton = Button(frame, text=_("Cancel"), width=8, command=self.close)
        ToolTip(cancelButton, text=_("Cancel operation, discarding changes and entries"))
        okButton = Button(frame, text=_("OK"), width=8, command=self.ok)
        ToolTip(okButton, text=_("Accept the options as entered above"))
        cancelButton.grid(row=16, column=1, columnspan=3, sticky=E, pady=3, padx=3)
        okButton.grid(row=16, column=1, columnspan=3, sticky=E, pady=3, padx=86)
        
        frame.grid(row=0, column=0, sticky=(N,S,E,W))
        frame.columnconfigure(2, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
        
        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)
        
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
Esempio n. 15
0
    def __init__(self, mainWin, options):
        parent = mainWin.parent
        super(DialogFind, self).__init__(parent)
        self.parent = parent
        self.modelManager = mainWin.modelManager
        self.modelXbrl = None   # set when Find pressed, this blocks next prematurely
        if options is None: options = newFindOptions
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
        dialogW = int(parentGeometry.group(1))
        dialogH = int(parentGeometry.group(2))
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("Find"))
        
        self.objsList = [] # next may be tried before anything is found
        
        frame = Frame(self)

        # load grid
        findLabel = gridHdr(frame, 1, 0, "Find:", anchor="w")
        findLabel.grid(padx=8)
        self.cbExpr = gridCombobox(frame, 1, 1, values=options["priorExpressions"])
        self.cbExpr.grid(columnspan=3, padx=8)
        ToolTip(self.cbExpr, text=_("Enter expression to find, or select from combo box drop down history list."), wraplength=240)

        y = 2
        
        # checkbox entries
        label(frame, 1, y, "Direction:")
        label(frame, 1, y + 3, "Match:")
        scopeLabel = label(frame, 2, y, "Scope:")
        ToolTip(scopeLabel, text=_("Scope for an XBRL document (instance or DTS).  "
                                   "For an RSS Feed, all properties are matched.  "), wraplength=240)
        rbUp = radiobutton(frame, 1, y+1, "Up", "up", "direction")
        ToolTip(rbUp, text=_("Find/Next up (on screen) from last to first match."), wraplength=240)
        rbDn = radiobutton(frame, 1, y+2, "Down", "down", "direction", rbUp.valueVar)
        ToolTip(rbDn, text=_("Find/Next down (on screen) from first to last match."), wraplength=240)
        rbText = radiobutton(frame, 1, y+4, "Text (ignore case)", "text", "exprType")
        ToolTip(rbText, text=_("Expression is a set of characters to match, ignoring case.  "
                               "The match may occur anywhere within the scope. "), wraplength=360)
        rbRegex = radiobutton(frame, 1, y+5, "Regular expression", "regex", "exprType", rbText.valueVar)
        ToolTip(rbRegex, text=_('A regular expression to match, anywhere in the scope, ignoring case.  '
                                'For example, "cash" would match cash anywhere in a string (like cash on hand), '
                                'whereas "^cash$" would match a full string to only contain cash. ' 
                                'Use regular expression metacharacters, e.g., "." for any single character, '
                                '".*" for any number of wild characters, .{3} for exactly 3 wild characters. '), wraplength=360)
        rbXPath = radiobutton(frame, 1, y+6, "XPath 2 expression", "xpath", "exprType", rbText.valueVar)
        ToolTip(rbXPath, text=_('An XPath 2 expression, where the context element, ".", is a candidate concept QName, if any concept scope is checked, '
                                'and a candidate fact item, if any fact scope is checked.  The XPath 2 functions do not need an "fn:" prefix (but it is defined).  '
                                'The XBRL Functions Registry functions do require an "xfi:" prefix.  Constructors require an "xs:" prefix.  '
                                'The expression is considered "matched" for the candidate concept QNames or fact items where the effective boolean value of the expression is "true()".  '), wraplength=360)
        self.optionControls = (
           rbUp,
           rbDn,
           rbText,
           rbRegex,
           rbXPath,
           #checkbox(frame, 2, y + 1, "All", "all"),
           checkbox(frame, 2, y + 1, "Concept label", "conceptLabel"),
           checkbox(frame, 2, y + 2, "   name", "conceptName"),
           checkbox(frame, 2, y + 3, "   type", "conceptType"),
           checkbox(frame, 2, y + 4, "   subs group", "conceptSubs"),
           checkbox(frame, 2, y + 5, "   period type", "conceptPer"),
           checkbox(frame, 2, y + 6, "   balance", "conceptBal"),
           checkbox(frame, 3, y + 1, "Fact label", "factLabel"),
           checkbox(frame, 3, y + 2, "   name", "factName"),
           checkbox(frame, 3, y + 3, "   value", "factValue"),
           checkbox(frame, 3, y + 4, "   context", "factCntx"),
           checkbox(frame, 3, y + 5, "   unit", "factUnit"),
           checkbox(frame, 3, y + 6, "Messages", "messagesLog"),
        
           # Note: if adding to this list keep Finder.FindOptions in sync
        
           )
        y += 7
        resultLabel = gridHdr(frame, 1, y, "Result:", anchor="w")
        resultLabel.grid(padx=8)
        self.resultText = gridCell(frame, 1, y + 1)
        self.resultText.grid(columnspan=3, padx=8)
        self.resultText.config(state="readonly")
        y += 2
        
        mainWin.showStatus(None)

        buttonFrame = Frame(frame)
        buttonFrame.grid(columnspan=4, sticky=E, padx=8)
        findButton = Button(buttonFrame, text=_("Find"), width=12, command=self.find)
        ToolTip(findButton, text=_('Compile (if regular expression or XPath 2), and find first match (if down direction) or last match (if up direction).  '), wraplength=240)
        nextButton = Button(buttonFrame, text=_("Next"), width=12, command=self.next)
        ToolTip(nextButton, text=_('Advance to the next matched object (in selected direction).  '), wraplength=240)
        closeButton = Button(buttonFrame, text=_("Close"), width=12, command=self.close)
        ToolTip(closeButton, text=_('Close the find dialog.  '), wraplength=240)
        findButton.grid(row=1, column=1, pady=3)
        nextButton.grid(row=1, column=2, pady=3)
        closeButton.grid(row=1, column=3, padx=3)
        
        frame.grid(row=0, column=0, sticky=(N,S,E,W))
        frame.columnconfigure(1, weight=1)
        frame.columnconfigure(2, weight=1)
        frame.columnconfigure(3, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        if self.options["geometry"]:
            self.geometry(self.options["geometry"])
        else:
            self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
        
        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)
        
        self.protocol("WM_DELETE_WINDOW", self.close)
        
        # make this dialog non-modal
        self.focus_set()
Esempio n. 16
0
    def __init__(self, mainWin, options, reportType, endDate):
        self.reportType = reportType
        self.mainWin = mainWin
        self.endDate = endDate
        parent = mainWin
        super(DialogCssfSaveOptions, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False
        self.accountingVersionValues = ACCOUNTING_VERSION_VALUES
        if reportType == SCOREP_REPORT:
            self.accountingVersionValues = self.accountingVersionValues + ACCOUNTING_SUBSIDIARY

        self.transient(self.parent)
        self.title(_("Save As CSSF Options"))
        
        frame = Frame(self)

        label(frame, 1, 1, _("Entity type:"))
        self.cellEntityType = gridCombobox(frame, 2, 1, getattr(options,"entityType",""), values=COMPANY_TYPE_VALUES)
        ToolTip(self.cellEntityType, text=_("Select an entity type"), wraplength=240)
        label(frame, 1, 2, _("CSSF entity code:"))
        self.cellCssfCode = gridCell(frame, 2, 2, getattr(options,"cssfCode",""))
        ToolTip(self.cellCssfCode, text=_("Enter a CSSF entity code (up to {0} digits)").format(CSSF_CODE_LENGTH), wraplength=240)
        currentRow = 3
        if reportType.endswith(COREP_REPORT_SUFFIX):
            label(frame, 1, currentRow, _("Ratio type:"))
            defaultValue = getattr(options, "ratioType","")
            if defaultValue not in RATIO_TYPE_VALUES:
                defaultValue = RATIO_TYPE_VALUES[0]
            self.cellRatioType = gridCombobox(frame, 2, currentRow, defaultValue, values=RATIO_TYPE_VALUES)
            ToolTip(self.cellRatioType, text=_("Select how the ratios are computed"), wraplength=240)
            currentRow += 1
        if reportType[0] != CONSOLIDATED_REPORT_PREFIX:
            label(frame, 1, currentRow, _("Accounting version:"))
            defaultValue = getattr(options, "accountingVersion", "")
            if defaultValue not in self.accountingVersionValues:
                defaultValue = ACCOUNTING_VERSION_DEFAULT
            self.cellAccountingVersion = gridCombobox(frame, 2, currentRow, defaultValue, values=self.accountingVersionValues)
            ToolTip(self.cellAccountingVersion, text=_("Select the accounting version"), wraplength=240)
            currentRow += 1
        if reportType == FINREP_REPORT:
            label(frame, 1, currentRow, _("Figures type:"))
            self.cellFiguresType = gridCombobox(frame, 2, currentRow, getattr(options,"figuresType",""), values=FIGURES_TYPE_VALUES)
            ToolTip(self.cellFiguresType, text=_("Select a figures type"), wraplength=240)
            currentRow += 1

        cancelButton = Button(frame, text=_("Cancel"), width=8, command=self.close)
        ToolTip(cancelButton, text=_("Cancel operation, discarding changes and entries"))
        okButton = Button(frame, text=_("OK"), width=8, command=self.ok)
        ToolTip(okButton, text=_("Accept the options as entered above"))
        cancelButton.grid(row=currentRow, column=1, columnspan=3, sticky=E, pady=3, padx=3)
        okButton.grid(row=currentRow, column=1, columnspan=3, sticky=E, pady=3, padx=86)
        
        frame.grid(row=0, column=0, sticky=(N,S,E,W))
        frame.columnconfigure(2, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
Esempio n. 17
0
    def bodyCells(self, row, yAxisParentObj, xFilters, zFilters,
                  yChildrenFirst):
        dimDefaults = self.modelXbrl.qnameDimensionDefaults
        priItemQnameErrors = set()
        dimQnameErrors = set()
        memQnameErrors = set()
        for axisMbrRel in self.axisMbrRelSet.fromModelObject(yAxisParentObj):
            yAxisHdrObj = axisMbrRel.toModelObject
            if yChildrenFirst:
                row = self.bodyCells(row, yAxisHdrObj, xFilters, zFilters,
                                     yChildrenFirst)
            if yAxisHdrObj.abstract == "false":
                yAxisPriItemQname = inheritedPrimaryItemQname(
                    self, yAxisHdrObj)
                yAxisExplicitDims = inheritedExplicitDims(self, yAxisHdrObj)

                gridSpacer(self.gridBody, self.dataFirstCol, row, LEFTBORDER)
                # data for columns of row
                ignoreDimValidity = self.ignoreDimValidity.get()
                zPriItemQname = None
                zDims = set()
                for zIndex in self.zFilterIndex:
                    zFilter = zFilters[zIndex]
                    if zFilter[0]:
                        zPriItemQname = zFilter[0]  # inherit pri item
                    zDims |= zFilter[1]  # or in z-dims
                for i, colFilter in enumerate(xFilters):
                    colPriItemQname = colFilter[0]  # y axis pri item
                    if not colPriItemQname:
                        colPriItemQname = yAxisPriItemQname  # y axis
                    if not colPriItemQname:
                        colPriItemQname = zPriItemQname  # z axis
                    fp = FactPrototype(
                        self, colPriItemQname,
                        yAxisExplicitDims | colFilter[1] | zDims)
                    from arelle.ValidateXbrlDimensions import isFactDimensionallyValid
                    value = None
                    objectId = None
                    justify = None
                    for fact in self.modelXbrl.facts:
                        if fact.qname == fp.qname:
                            factDimMem = fact.context.dimMemberQname
                            defaultedDims = _DICT_SET(
                                dimDefaults.keys()) - fp.dimKeys
                            if (all(
                                    factDimMem(dim, includeDefaults=True) ==
                                    mem for dim, mem in fp.dims) and all(
                                        factDimMem(dim, includeDefaults=True)
                                        in (dimDefaults[dim], None)
                                        for dim in defaultedDims)):
                                value = fact.effectiveValue
                                objectId = fact.objectId()
                                justify = "right" if fact.isNumeric else "left"
                                break
                    if 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:
                        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, yAxisHdrObj, xFilters, zFilters,
                                     yChildrenFirst)
        return row
Esempio n. 18
0
    def __init__(self, mainWin, options):
        parent = mainWin.parent
        super(DialogFormulaParameters, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("Formula Parameters and Trace Options"))
        
        frame = Frame(self)

        '''
        dialogFrame = Frame(frame, width=500)
        dialogFrame.columnconfigure(0, weight=1)
        dialogFrame.rowconfigure(0, weight=1)
        dialogFrame.grid(row=0, column=0, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
        '''
        
        # mainWin.showStatus(_("loading formula options and parameters"))
        
        # load grid
        gridHdr(frame, 1, 0, "Parameters", columnspan=3)
        gridHdr(frame, 1, 1, "QName")
        gridHdr(frame, 2, 1, "Type")
        gridHdr(frame, 3, 1, "Value")
        
        self.gridCells = []
        y = 2
        dataTypes = ("xs:string", "xs:integer", "xs:decimal", "xs:date", "xs:datetime", "xs:QName")
        for parameter in options["parameterValues"].items():
            paramQname, paramTypeValue = parameter
            if isinstance(paramTypeValue, (tuple,list)):
                paramType, paramValue = paramTypeValue  # similar to modelTestcaseObject, where values() are (type,value)
            else:
                paramType = None
                paramValue = paramTypeValue
            self.gridCells.append( (
                gridCell(frame, 1, y, paramQname),
                gridCombobox(frame, 2, y, paramType, values=dataTypes),
                gridCell(frame, 3, y, paramValue)) )
            y += 1
        # extra entry for new cells
        for i in range(5):
            self.gridCells.append( (
                gridCell(frame, 1, y),
                gridCombobox(frame, 2, y, values=dataTypes),
                gridCell(frame, 3, y)) )
            y += 1
        y += 1
        
        # checkbox entries
        label(frame, 1, y, "Parameter Trace:")
        label(frame, 1, y + 3, "API Calls Trace:")
        label(frame, 2, y, "Variable Set Trace:")
        label(frame, 3, y, "Variables Trace:")
        self.checkboxes = (
           checkbox(frame, 1, y + 1, 
                    "Expression Result", 
                    "traceParameterExpressionResult"),
           checkbox(frame, 1, y + 2,
                    "Input Value", 
                    "traceParameterInputValue"),
           checkbox(frame, 1, y + 4, 
                    "Expression Source", 
                    "traceCallExpressionSource"),
           checkbox(frame, 1, y + 5, 
                    "Expression Code", 
                    "traceCallExpressionCode"),
           checkbox(frame, 1, y + 6, 
                    "Expression Evaluation", 
                    "traceCallExpressionEvaluation"),
           checkbox(frame, 1, y + 7,
                    "Expression Result", 
                    "traceCallExpressionResult"),

           checkbox(frame, 2, y + 1, 
                    "Expression Source", 
                    "traceVariableSetExpressionSource"),
           checkbox(frame, 2, y + 2, 
                    "Expression Code", 
                    "traceVariableSetExpressionCode"),
           checkbox(frame, 2, y + 3, 
                    "Expression Evaluation", 
                    "traceVariableSetExpressionEvaluation"),
           checkbox(frame, 2, y + 4,
                    "Expression Result", 
                    "traceVariableSetExpressionResult"),
           checkbox(frame, 2, y + 5,
                    "Assertion Result Counts", 
                    "traceAssertionResultCounts"),
           checkbox(frame, 2, y + 6,
                    "Formula Rules", 
                    "traceFormulaRules"),
           checkbox(frame, 3, y + 1, 
                    "Variable Dependencies", 
                    "traceVariablesDependencies"),
           checkbox(frame, 3, y + 2, 
                    "Variables Order", 
                    "traceVariablesOrder"),
           checkbox(frame, 3, y + 3, 
                    "Expression Source", 
                    "traceVariableExpressionSource"),
           checkbox(frame, 3, y + 4, 
                    "Expression Code", 
                    "traceVariableExpressionCode"),
           checkbox(frame, 3, y + 5, 
                    "Expression Evaluation", 
                    "traceVariableExpressionEvaluation"),
           checkbox(frame, 3, y + 6, 
                    "Expression Result", 
                    "traceVariableExpressionResult"),
           checkbox(frame, 3, y + 7, 
                    "Filter Winnowing", 
                    "traceVariableFilterWinnowing"),
           checkbox(frame, 3, y + 8, 
                    "Filters Result", 
                    "traceVariableFiltersResult")
        
           # Note: if adding to this list keep ModelFormulaObject.FormulaOptions in sync
        
           )
        y += 9
        
        mainWin.showStatus(None)

        okButton = Button(frame, text=_("OK"), width=12, command=self.ok)
        cancelButton = Button(frame, text=_("Cancel"), width=12, command=self.close)
        okButton.grid(row=y, column=2, sticky=E, pady=3)
        cancelButton.grid(row=y, column=3, sticky=E, pady=3, padx=3)
        
        frame.grid(row=0, column=0, sticky=(N,S,E,W))
        frame.columnconfigure(1, weight=3)
        frame.columnconfigure(2, weight=1)
        frame.columnconfigure(3, weight=3)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
        
        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)
        
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
Esempio n. 19
0
 def bodyCells(self, row, yParentStructuralNode, xStructuralNodes, zAspectStructuralNodes, 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, zAspectStructuralNodes, yChildrenFirst)
             if not (yStructuralNode.isAbstract or 
                     (yStructuralNode.childStructuralNodes and
                      not isinstance(yStructuralNode.definitionNode, (ModelClosedDefinitionNode, ModelEuAxisCoord)))) and yStructuralNode.isLabeled:
                 isEntryPrototype = yStructuralNode.isEntryPrototype(default=False) # row to enter open aspects
                 yAspectStructuralNodes = defaultdict(set)
                 for aspect in aspectModels[self.aspectModel]:
                     if yStructuralNode.hasAspect(aspect):
                         if aspect == Aspect.DIMENSIONS:
                             for dim in (yStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                 yAspectStructuralNodes[dim].add(yStructuralNode)
                         else:
                             yAspectStructuralNodes[aspect].add(yStructuralNode)
                 yTagSelectors = yStructuralNode.tagSelectors
                 gridSpacer(self.gridBody, self.dataFirstCol, row, LEFTBORDER)
                 # data for columns of row
                 #print ("row " + str(row) + "yNode " + yStructuralNode.definitionNode.objectId() )
                 ignoreDimValidity = self.ignoreDimValidity.get()
                 for i, xStructuralNode in enumerate(xStructuralNodes):
                     xAspectStructuralNodes = defaultdict(set)
                     for aspect in aspectModels[self.aspectModel]:
                         if xStructuralNode.hasAspect(aspect):
                             if aspect == Aspect.DIMENSIONS:
                                 for dim in (xStructuralNode.aspectValue(Aspect.DIMENSIONS) or emptyList):
                                     xAspectStructuralNodes[dim].add(xStructuralNode)
                             else:
                                 xAspectStructuralNodes[aspect].add(xStructuralNode)
                     cellTagSelectors = yTagSelectors | xStructuralNode.tagSelectors
                     cellAspectValues = {}
                     matchableAspects = set()
                     for aspect in _DICT_SET(xAspectStructuralNodes.keys()) | _DICT_SET(yAspectStructuralNodes.keys()) | _DICT_SET(zAspectStructuralNodes.keys()):
                         aspectValue = xStructuralNode.inheritedAspectValue(yStructuralNode,
                                            self, aspect, cellTagSelectors, 
                                            xAspectStructuralNodes, yAspectStructuralNodes, zAspectStructuralNodes)
                         # value is None for a dimension whose value is to be not reported in this slice
                         if (isinstance(aspect, _INT) or  # not a dimension
                             dimDefaults.get(aspect) != aspectValue or # explicit dim defaulted will equal the value
                             aspectValue is not None): # typed dim absent will be none
                             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
                                 elif aspectValue is None: # match typed dims that don't report this value
                                     dimMemQname = ModelXbrl.DEFAULT
                                 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) or
                          isEntryPrototype)):
                         if objectId is None:
                             objectId = "f{0}".format(len(self.factPrototypes))
                             self.factPrototypes.append(fp)  # for property views
                             for aspect, aspectValue in cellAspectValues.items():
                                 if isinstance(aspectValue, str) and aspectValue.startswith(OPEN_ASPECT_ENTRY_SURROGATE):
                                     self.factPrototypeAspectEntryObjectIds[objectId].add(aspectValue) 
                         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, zAspectStructuralNodes, yChildrenFirst)
         return row
Esempio n. 20
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
Esempio n. 21
0
    def __init__(self, mainWin, options):
        self.mainWin = mainWin
        parent = mainWin.parent
        super(DialogRssWatch, self).__init__(parent)
        self.parent = parent
        self.options = options
        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)",
                                  parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))
        self.accepted = False

        self.transient(self.parent)
        self.title(_("RSS Feed Processing Control"))

        frame = Frame(self)
        frame.focus_set()

        # checkbox entries
        row = 1  # row number (to allow future plugins
        label(frame, 1, row, "RSS Feed:")
        feedSources = sorted(rssFeeds.keys())
        self.cellFeed = gridCombobox(frame,
                                     2,
                                     row,
                                     options.get("feedSource", ""),
                                     values=feedSources)
        self.cellFeed.grid(pady=2)
        ToolTip(
            self.cellFeed,
            text=
            _("Select an RSS feed to process for item matching, formulas, and validations as selected below"
              ),
            wraplength=240)
        row += 1
        label(frame, 1, row, "Match fact text:")
        self.cellMatchText = gridCell(frame, 2, row,
                                      options.get("matchTextExpr", ""))
        ToolTip(
            self.cellMatchText,
            text=
            _("Enter a regular expression to be matched to the text of each filing instance fact item. "
              "Regular expressions may contain patterns to detect, such as ab.?c, for any single character between b and c, or ab.*c for any number of characters between b and c."
              ),
            wraplength=240)
        row += 1
        label(frame, 1, row, "Formula file:")
        self.cellFormulaFile = gridCell(frame, 2, row,
                                        options.get("formulaFileUri", ""))
        ToolTip(
            self.cellFormulaFile,
            text=
            _("Select a formula linkbase to to evaluate each filing.  "
              "The formula linkbase may contain one or more assertions, the results of which is recorded in the log file.  "
              "If unsuccessful assertion alerts are selected and an e-mail address provided, the recipient will be notified of filings with assertions that do not pass."
              ),
            wraplength=240)
        openFileImage = PhotoImage(
            file=os.path.join(mainWin.imagesDir, "toolbarOpenFile.gif"))
        chooseFormulaFileButton = Button(frame,
                                         image=openFileImage,
                                         width=12,
                                         command=self.chooseFormulaFile)
        chooseFormulaFileButton.grid(row=row, column=3, sticky=W)
        row += 1
        openDatabaseImage = PhotoImage(
            file=os.path.join(mainWin.imagesDir, "toolbarOpenDatabase.gif"))
        for pluginXbrlMethod in pluginClassMethods(
                "DialogRssWatch.FileChoices"):
            pluginXbrlMethod(self, frame, row, options, mainWin, openFileImage,
                             openDatabaseImage)
            row += 1
        label(frame, 1, row, "Log file:")
        self.cellLogFile = gridCell(frame, 2, row,
                                    options.get("logFileUri", ""))
        ToolTip(
            self.cellLogFile,
            text=
            _("Select a log file in which to save an activity log, including validation results, matched item text, and formula results.\n\n "
              "If file ends in .xml it is xml-formatted, otherwise it is text. "
              ),
            wraplength=240)
        chooseLogFileButton = Button(frame,
                                     image=openFileImage,
                                     width=12,
                                     command=self.chooseLogFile)
        chooseLogFileButton.grid(row=row, column=3, sticky=W)
        row += 1
        label(frame, 1, row, "E-mail alerts to:")
        self.cellEmailAddress = gridCell(frame, 2, row,
                                         options.get("emailAddress", ""))
        ToolTip(self.cellEmailAddress,
                text=_("Specify e-mail recipient(s) for alerts per below."),
                wraplength=240)
        propertiesImage = PhotoImage(
            file=os.path.join(mainWin.imagesDir, "toolbarProperties.gif"))
        smtpSetupButton = Button(frame,
                                 image=propertiesImage,
                                 width=12,
                                 command=self.setupSmtp)
        smtpSetupButton.grid(row=row, column=3, sticky=W)
        ToolTip(
            smtpSetupButton,
            text=_("Enter/edit settings of outgoing e-mail server (SMTP)."),
            wraplength=240)
        row += 1
        label(frame, 1, row, "Latest pub date:")
        pubdate = getattr(options, "latestPubDate", None)
        self.cellLatestPubDate = gridCell(frame, 2, row,
                                          str(pubdate) if pubdate else "")
        ToolTip(
            self.cellLatestPubDate,
            text=
            _("Specify pub dateTime of last processed submission.  Next item to examine will be after this dateTime."
              ),
            wraplength=240)
        clearImage = PhotoImage(
            file=os.path.join(mainWin.imagesDir, "toolbarDelete.gif"))
        clearPubDateButton = Button(frame,
                                    image=clearImage,
                                    width=12,
                                    command=self.clearPubDate)
        clearPubDateButton.grid(row=row, column=3, sticky=W)
        ToolTip(
            clearPubDateButton,
            text=
            _("Clear pub dateTime so that next cycle processes all entries in RSS feed."
              ),
            wraplength=240)
        row += 1
        label(frame, 2, row, "Validate:")
        row += 1
        self.checkboxes = (
            checkbox(frame, 2, row, "XBRL 2.1 and Dimensions rules",
                     "validateXbrlRules"),
            checkbox(frame, 2, row + 1, "Selected disclosure system rules",
                     "validateDisclosureSystemRules"),
            checkbox(frame, 2, row + 2, "Calculation linkbase roll-up",
                     "validateCalcLinkbase"),
            checkbox(frame, 2, row + 3, "Formula assertions",
                     "validateFormulaAssertions"),
            # Note: if adding to this list keep ModelFormulaObject.FormulaOptions in sync
        )
        row += 4
        for pluginXbrlMethod in pluginClassMethods(
                "DialogRssWatch.ValidateChoices"):
            pluginXbrlMethod(self, frame, row, options, mainWin)
            row += 1
        label(frame, 2, row, "Alert on:")
        row += 1
        self.checkboxes += (
            checkbox(frame, 2, row, "Facts with matching text",
                     "alertMatchedFactText"),
            checkbox(frame, 2, row + 1, "Unsuccessful formula assertions",
                     "alertAssertionUnsuccessful"),
            checkbox(frame, 2, row + 2, "Validation errors",
                     "alertValiditionError"),
            # Note: if adding to this list keep ModelFormulaObject.FormulaOptions in sync
        )
        row += 3

        mainWin.showStatus(None)

        cancelButton = Button(frame,
                              text=_("Cancel"),
                              width=8,
                              command=self.close)
        ToolTip(cancelButton,
                text=_("Cancel operation, discarding changes and entries"))
        okButton = Button(frame, text=_("OK"), width=8, command=self.ok)
        ToolTip(okButton, text=_("Accept the options as entered above"))
        cancelButton.grid(row=row,
                          column=1,
                          columnspan=3,
                          sticky=E,
                          pady=3,
                          padx=3)
        okButton.grid(row=row,
                      column=1,
                      columnspan=3,
                      sticky=E,
                      pady=3,
                      padx=86)

        frame.grid(row=0, column=0, sticky=(N, S, E, W))
        frame.columnconfigure(2, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        self.geometry("+{0}+{1}".format(dialogX + 50, dialogY + 100))

        #self.bind("<Return>", self.ok)
        #self.bind("<Escape>", self.close)

        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)