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


Python arelle.ValidateXbrlDimensions类代码示例

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


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

示例1: insertXbrl

 def insertXbrl(self, rssItem):
     try:
         # must also have default dimensions loaded
         from arelle import ValidateXbrlDimensions
         ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
         
         startedAt = time.time()
         # self.load()  this done in the verify step
         self.insertAccession(rssItem)
         self.insertDocuments()
         self.insertDataDictionary() # XML namespaces types aspects
         #self.insertRelationshipTypeSets()
         #self.insertResourceRoleSets()
         #self.insertAspectValues()
         #self.insertResources()
         self.modelXbrl.profileStat(_("XbrlPublicDB: DTS insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertDataPoints()
         self.modelXbrl.profileStat(_("XbrlPublicDB: data points insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertRelationshipSets()
         self.modelXbrl.profileStat(_("XbrlPublicDB: Relationships insertion"), time.time() - startedAt)
         #startedAt = time.time()
         #self.insertValidCombinations()
         #self.modelXbrl.profileStat(_("XbrlPublicDB: Valid Combinations insertion"), time.time() - startedAt)
         self.showStatus("Committing entries")
         self.commit()
         self.modelXbrl.profileStat(_("XbrlPublicDB: insertion committed"), time.time() - startedAt)
         self.showStatus("DB insertion completed", clearAfter=5000)
     except Exception as ex:
         self.showStatus("DB insertion failed due to exception", clearAfter=5000)
         raise
开发者ID:fukkun,项目名称:Arelle,代码行数:32,代码来源:XbrlSemanticGraphDB.py

示例2: insertXbrl

 def insertXbrl(self, rssItem):
     try:
         # must also have default dimensions loaded
         from arelle import ValidateXbrlDimensions
         ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
                     
         # find pre-existing documents in server database
         self.identifyPreexistingDocuments()
         self.identifyConceptsUsed()
         
         startedAt = time.time()
         self.insertAccession(rssItem)
         self.insertUris()
         self.insertQnames()
         self.insertNamespaces()
         self.insertDocuments()
         self.insertCustomArcroles()
         self.insertCustomRoles()
         self.insertElements()
         self.insertResources()
         self.insertNetworks()
         self.modelXbrl.profileStat(_("XbrlPublicDB: DTS insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertFacts()
         self.modelXbrl.profileStat(_("XbrlPublicDB: instance insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.showStatus("Committing entries")
         self.commit()
         self.modelXbrl.profileStat(_("XbrlPublicDB: insertion committed"), time.time() - startedAt)
         self.showStatus("DB insertion completed", clearAfter=5000)
     except Exception as ex:
         self.showStatus("DB insertion failed due to exception", clearAfter=5000)
         raise
开发者ID:jasonleinbach-wf,项目名称:Arelle-1,代码行数:33,代码来源:XbrlPublicPostgresDB.py

示例3: insertXbrl

    def insertXbrl(self, rssItem):
        try:
            # must also have default dimensions loaded
            from arelle import ValidateXbrlDimensions
            ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
            
            # must have a valid XBRL instance or document
            if self.modelXbrl.modelDocument is None:
                raise XPDBException("xpgDB:MissingXbrlDocument",
                                    _("No XBRL instance or schema loaded for this filing.")) 
            
            # at this point we determine what's in the database and provide new tables
            # requires locking most of the table structure
            self.lockTables(("dAvailableTable", "dInstance",  "dFact", "dFilingIndicator",
                             # "dProcessingContext", "dProcessingFact"
                             ))
            
            self.dropTemporaryTable()
 
            startedAt = time.time()
            self.insertInstance()
            self.insertDataPoints()
            self.modelXbrl.profileStat(_("XbrlSqlDB: instance insertion"), time.time() - startedAt)
            
            startedAt = time.time()
            self.showStatus("Committing entries")
            self.commit()
            self.modelXbrl.profileStat(_("XbrlSqlDB: insertion committed"), time.time() - startedAt)
            self.showStatus("DB insertion completed", clearAfter=5000)
        except Exception as ex:
            self.showStatus("DB insertion failed due to exception", clearAfter=5000)
            raise
开发者ID:vincejolivet,项目名称:Arelle,代码行数:32,代码来源:XbrlDpmSqlDB.py

示例4: start

 def start(self, tag, attrib, nsmap=None):
     mdlObj = _parser.makeelement(tag, attrib=attrib, nsmap=nsmap)
     mdlObj.sourceline = 1
     if self.newTree:
         self.newTree = False
         self.currentMdlObj = mdlObj
         modelDocument = ModelDocument(modelXbrl, Type.INSTANCE, mappedUri, filepath, mdlObj.getroottree())
         modelXbrl.modelDocument = modelDocument # needed for incremental validation
         mdlObj.init(modelDocument)
         modelDocument.parser = _parser # needed for XmlUtil addChild's makeelement 
         modelDocument.parserLookupName = _parserLookupName
         modelDocument.parserLookupClass = _parserLookupClass
         modelDocument.xmlRootElement = mdlObj
         modelDocument.schemaLocationElements.add(mdlObj)
         modelDocument.documentEncoding = _encoding
         modelDocument._creationSoftwareComment = creationSoftwareComment
         modelXbrl.info("streamingExtensions:streaming",
                        _("Stream processing this instance."),
                        modelObject = modelDocument)    
     else:
         self.currentMdlObj.append(mdlObj)
         self.currentMdlObj = mdlObj
         mdlObj._init()
         ns = mdlObj.namespaceURI
         ln = mdlObj.localName
         if (self.beforeInstanceStream and (
             (ns == XbrlConst.link and ln not in ("schemaRef", "linkbaseRef")) or
             (ns == XbrlConst.xbrli and ln in ("context", "unit")) or
             (ns not in (XbrlConst.link, XbrlConst.xbrli)))):
             self.beforeInstanceStream = False
             if _streamingExtensionsValidate:
                 instValidator.validate(modelXbrl, modelXbrl.modelManager.formulaOptions.typedParameters())
             else: # need default dimensions
                 ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
     return mdlObj
开发者ID:jcjones1515,项目名称:Arelle,代码行数:35,代码来源:streamingExtensions.py

示例5: viewRenderedGrid

def viewRenderedGrid(modelXbrl, tabWin, lang=None):
    modelXbrl.modelManager.showStatus(_("viewing rendering"))
    view = ViewRenderedGrid(modelXbrl, tabWin, lang)
    
    # dimension defaults required in advance of validation
    from arelle import ValidateXbrlDimensions
    ValidateXbrlDimensions.loadDimensionDefaults(view)
    
    # context menu
    setDefaults(view)
    menu = view.contextMenu()
    optionsMenu = Menu(view.viewFrame, tearoff=0)
    view.ignoreDimValidity.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("Ignore Dimensional Validity"), underline=0, variable=view.ignoreDimValidity, onvalue=True, offvalue=False)
    view.xAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("X-Axis Children First"), underline=0, variable=view.xAxisChildrenFirst, onvalue=True, offvalue=False)
    view.yAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("Y-Axis Children First"), underline=0, variable=view.yAxisChildrenFirst, onvalue=True, offvalue=False)
    menu.add_cascade(label=_("Options"), menu=optionsMenu, underline=0)
    view.tablesMenu = Menu(view.viewFrame, tearoff=0)
    menu.add_cascade(label=_("Tables"), menu=view.tablesMenu, underline=0)
    view.tablesMenuLength = 0
    view.menuAddLangs()
    view.menu.add_command(label=_("Save html file"), underline=0, command=lambda: view.modelXbrl.modelManager.cntlr.fileSave(view=view))
    view.view()
    view.blockSelectEvent = 1
    view.blockViewModelObject = 0
    view.viewFrame.bind("<Enter>", view.cellEnter, '+')
    view.viewFrame.bind("<Leave>", view.cellLeave, '+')
开发者ID:marado,项目名称:Arelle,代码行数:29,代码来源:ViewWinRenderedGrid.py

示例6: backgroundProfileFormula

def backgroundProfileFormula(cntlr, profileReportFile, maxRunTime, excludeCompileTime):
    from arelle import Locale, XPathParser, ValidateXbrlDimensions, ValidateFormula

    # build grammar before profiling (if this is the first pass, so it doesn't count in profile statistics)
    XPathParser.initializeParser(cntlr.modelManager)
    
    # load dimension defaults
    ValidateXbrlDimensions.loadDimensionDefaults(cntlr.modelManager)
    
    import cProfile, pstats, sys, time
    
    # a minimal validation class for formula validator parameters that are needed
    class Validate:
        def __init__(self, modelXbrl, maxRunTime):
            self.modelXbrl = modelXbrl
            self.parameters = None
            self.validateSBRNL = False
            self.maxFormulaRunTime = maxRunTime
        def close(self):
            self.__dict__.clear()
            
    val = Validate(cntlr.modelManager.modelXbrl, maxRunTime)
    formulaOptions = val.modelXbrl.modelManager.formulaOptions
    if excludeCompileTime:
        startedAt = time.time()
        cntlr.addToLog(_("pre-compiling formulas before profiling"))
        val.validateFormulaCompileOnly = True
        ValidateFormula.validate(val)
        del val.validateFormulaCompileOnly
        cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale, 
                                            _("formula pre-compiling completed in %.2f secs"), 
                                            time.time() - startedAt))
        cntlr.addToLog(_("executing formulas for profiling"))
    else:
        cntlr.addToLog(_("compiling and executing formulas for profiling"))
    startedAt = time.time()
            
    statsFile = profileReportFile + ".bin"
    cProfile.runctx("ValidateFormula.validate(val)", globals(), locals(), statsFile)
    cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale, 
                                        _("formula profiling completed in %.2f secs"), 
                                        time.time() - startedAt))
    # dereference val
    val.close()
    
    # specify a file for log
    priorStdOut = sys.stdout
    sys.stdout = open(profileReportFile, "w")

    statObj = pstats.Stats(statsFile)
    statObj.strip_dirs()
    statObj.sort_stats("time")
    statObj.print_stats()
    statObj.print_callees()
    statObj.print_callers()
    sys.stdout.flush()
    sys.stdout.close()
    del statObj
    sys.stdout = priorStdOut
    os.remove(statsFile)
开发者ID:Arelle,项目名称:Arelle,代码行数:60,代码来源:profileFormula.py

示例7: viewRenderedGrid

def viewRenderedGrid(modelXbrl, outfile, lang=None, viewTblELR=None, sourceView=None):
    modelXbrl.modelManager.showStatus(_("viewing rendering"))
    view = ViewRenderedGrid(modelXbrl, outfile, lang)
    
    # dimension defaults required in advance of validation
    from arelle import ValidateXbrlDimensions
    ValidateXbrlDimensions.loadDimensionDefaults(view)
    setDefaults(view)
    if sourceView is not None:
        viewTblELR = sourceView.tblELR
        view.ignoreDimValidity.set(sourceView.ignoreDimValidity.get())
        view.xAxisChildrenFirst.set(sourceView.xAxisChildrenFirst.get())
        view.yAxisChildrenFirst.set(sourceView.yAxisChildrenFirst.get())
    view.view(viewTblELR)    
    view.close()
开发者ID:Bourne-Law,项目名称:Arelle,代码行数:15,代码来源:ViewFileRenderedGrid.py

示例8: insertXbrl

 def insertXbrl(self, rssItem):
     try:
         # must also have default dimensions loaded
         from arelle import ValidateXbrlDimensions
         ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
         
         #initialVcount, initialEcount = self.getDBsize() # don't include in timing, very slow
         startedAt = time.time()
         
         # find pre-existing documents in server database
         self.identifyPreexistingDocuments()
         
         g = {FILINGS:{},
              DOCUMENTS:{}}
         self.insertSchema(g)
         
         # self.load()  this done in the verify step
         self.insertFiling(rssItem,g)
         self.insertDocuments(g)
         self.insertDataDictionary() # XML namespaces types aspects
         #self.insertRelationshipTypeSets()
         #self.insertResourceRoleSets()
         #self.insertAspectValues()
         self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: DTS insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertDataPoints()
         self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: data points insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertRelationshipSets()
         self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: Relationships insertion"), time.time() - startedAt)
         self.insertValidationResults()
         self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: Validation results insertion"), time.time() - startedAt)
         #startedAt = time.time()
         #self.insertValidCombinations()
         #self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: Valid Combinations insertion"), time.time() - startedAt)
         self.showStatus("Committing entries")
         self.commit(g)
         self.modelXbrl.profileStat(_("XbrlSemanticJsonDB: insertion committed"), time.time() - startedAt)
         #finalVcount, finalEcount = self.getDBsize()
         #self.modelXbrl.modelManager.addToLog("added vertices: {0}, edges: {1}, total vertices: {2}, edges: {3}".format(
         #              finalVcount - initialVcount, finalEcount - initialEcount, finalVcount, finalEcount))
         self.showStatus("DB insertion completed", clearAfter=5000)
     except Exception as ex:
         self.showStatus("DB insertion failed due to exception", clearAfter=5000)
         raise
开发者ID:Arelle,项目名称:Arelle,代码行数:45,代码来源:XbrlSemanticJsonDB.py

示例9: saveTargetDocument

    def saveTargetDocument(self):
        targetUrl = self.modelXbrl.modelManager.cntlr.webCache.normalizeUrl(self.targetDocumentPreferredFilename, self.filepath)
        targetUrlParts = targetUrl.rpartition(".")
        targetUrl = targetUrlParts[0] + "_extracted." + targetUrlParts[2]
        self.modelXbrl.modelManager.showStatus(_("Extracting instance ") + os.path.basename(targetUrl))
        targetInstance = ModelXbrl.create(self.modelXbrl.modelManager, 
                                          newDocumentType=Type.INSTANCE,
                                          url=targetUrl,
                                          schemaRefs=self.targetDocumentSchemaRefs,
                                          isEntry=True)
        ValidateXbrlDimensions.loadDimensionDefaults(targetInstance) # need dimension defaults 
        for context in self.modelXbrl.contexts.values():
            newCntx = targetInstance.createContext(context.entityIdentifier[0],
                                                   context.entityIdentifier[1],
                                                   'instant' if context.isInstantPeriod else
                                                   'duration' if context.isStartEndPeriod
                                                   else 'forever',
                                                   context.startDatetime,
                                                   context.endDatetime,
                                                   None, 
                                                   context.qnameDims, [], [],
                                                   id=context.id)
        for unit in self.modelXbrl.units.values():
            measures = unit.measures
            newUnit = targetInstance.createUnit(measures[0], measures[1], id=unit.id)

        self.modelXbrl.modelManager.showStatus(_("Creating and validating facts"))
        for fact in self.modelXbrl.facts:
            if fact.isItem:
                attrs = [("contextRef", fact.contextID)]
                if fact.isNumeric:
                    attrs.append(("unitRef", fact.unitID))
                    if fact.get("decimals"):
                        attrs.append(("decimals", fact.get("decimals")))
                    if fact.get("precision"):
                        attrs.append(("precision", fact.get("precision")))
                if fact.isNil:
                    attrs.append(("{http://www.w3.org/2001/XMLSchema-instance}nil","true"))
                    text = None
                else:
                    text = fact.xValue if fact.xValid else fact.elementText
                newFact = targetInstance.createFact(fact.qname, attributes=attrs, text=text)
        targetInstance.saveInstance(overrideFilepath=targetUrl)
        self.modelXbrl.modelManager.showStatus(_("Saved extracted instance"), 5000)
开发者ID:andygreener,项目名称:Arelle,代码行数:44,代码来源:inlineXbrlDocumentSet.py

示例10: insertXbrl

 def insertXbrl(self, rssItem):
     try:
         # must also have default dimensions loaded
         from arelle import ValidateXbrlDimensions
         ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
         
         # get logging entries (needed to find which aspects to identify)
         self.loggingEntries = []
         for handler in logging.getLogger("arelle").handlers:
             if hasattr(handler, "dbHandlerLogEntries"):
                 self.loggingEntries = handler.dbHandlerLogEntries()
                 break
                     
         # find pre-existing documents in server database
         self.identifyPreexistingDocuments()
         self.identifyAspectsUsed()
         
         startedAt = time.time()
         self.dropTemporaryTable()
         self.insertFiling(rssItem)
         self.insertDocuments()
         self.insertAspects()
         self.insertArcroleTypes()
         self.insertRoleTypes()
         self.insertResources()
         self.insertRelationships()
         self.modelXbrl.profileStat(_("XbrlSqlDB: DTS insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertDataPoints()
         self.modelXbrl.profileStat(_("XbrlSqlDB: instance insertion"), time.time() - startedAt)
         self.insertValidationResults()
         self.modelXbrl.profileStat(_("XbrlSqlDB: Validation results insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.showStatus("Committing entries")
         self.commit()
         self.modelXbrl.profileStat(_("XbrlSqlDB: insertion committed"), time.time() - startedAt)
         self.showStatus("DB insertion completed", clearAfter=5000)
     except Exception as ex:
         self.showStatus("DB insertion failed due to exception", clearAfter=5000)
         raise
开发者ID:SrikanthSrinivasan,项目名称:Arelle,代码行数:40,代码来源:XbrlSemanticSqlDB.py

示例11: insertXbrl

 def insertXbrl(self, rssItem):
     try:
         # must also have default dimensions loaded
         from arelle import ValidateXbrlDimensions
         ValidateXbrlDimensions.loadDimensionDefaults(self.modelXbrl)
                     
         # obtain supplementaion entity information
         self.entityInformation = loadEntityInformation(self.modelXbrl, rssItem)
         # identify table facts (table datapoints) (prior to locked database transaction
         self.tableFacts = tableFacts(self.modelXbrl)  # for EFM & HMRC this is ( (roleType, table_code, fact) )
         loadPrimaryDocumentFacts(self.modelXbrl, rssItem, self.entityInformation) # load primary document facts for SEC filing
         
         # find pre-existing documents in server database
         self.identifyPreexistingDocuments()
         self.identifyConceptsUsed()
         
         startedAt = time.time()
         self.insertAccession(rssItem)
         self.insertUris()
         self.insertQnames()
         self.insertNamespaces()
         self.insertDocuments()
         self.insertCustomArcroles()
         self.insertCustomRoles()
         self.insertElements()
         self.insertResources()
         self.insertNetworks()
         self.modelXbrl.profileStat(_("XbrlPublicDB: DTS insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.insertFacts()
         self.modelXbrl.profileStat(_("XbrlPublicDB: instance insertion"), time.time() - startedAt)
         startedAt = time.time()
         self.showStatus("Committing entries")
         self.commit()
         self.modelXbrl.profileStat(_("XbrlPublicDB: insertion committed"), time.time() - startedAt)
         self.showStatus("DB insertion completed", clearAfter=5000)
     except Exception as ex:
         self.showStatus("DB insertion failed due to exception", clearAfter=5000)
         raise
开发者ID:OpenDisclosure,项目名称:XBRL,代码行数:39,代码来源:XbrlPublicPostgresDB.py

示例12: run


#.........这里部分代码省略.........
                    success = False
                else:
                    loadTime = time.time() - startedAt
                    modelXbrl.profileStat(_("load"), loadTime)
                    self.addToLog(format_string(self.modelManager.locale, 
                                                _("diff comparison DTS loaded in %.2f secs"), 
                                                loadTime), 
                                                messageCode="info", file=self.entrypointFile)
                    startedAt = time.time()
                    modelDiffReport = self.modelManager.compareDTSes(options.versReportFile)
                    diffTime = time.time() - startedAt
                    modelXbrl.profileStat(_("diff"), diffTime)
                    self.addToLog(format_string(self.modelManager.locale, 
                                                _("compared in %.2f secs"), 
                                                diffTime), 
                                                messageCode="info", file=self.entrypointFile)
            except ModelDocument.LoadingException:
                success = False
            except Exception as err:
                success = False
                self.addToLog(_("[Exception] Failed to doad diff file: \n{0} \n{1}").format(
                            err,
                            traceback.format_tb(sys.exc_info()[2])))
        if success:
            try:
                modelXbrl = self.modelManager.modelXbrl
                hasFormulae = modelXbrl.hasFormulae
                if options.validate:
                    startedAt = time.time()
                    if options.formulaAction: # don't automatically run formulas
                        modelXbrl.hasFormulae = False
                    self.modelManager.validate()
                    if options.formulaAction: # restore setting
                        modelXbrl.hasFormulae = hasFormulae
                    self.addToLog(format_string(self.modelManager.locale, 
                                                _("validated in %.2f secs"), 
                                                time.time() - startedAt),
                                                messageCode="info", file=self.entrypointFile)
                if options.formulaAction in ("validate", "run"):  # do nothing here if "none"
                    from arelle import ValidateXbrlDimensions, ValidateFormula
                    startedAt = time.time()
                    if not options.validate:
                        ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
                    # setup fresh parameters from formula optoins
                    modelXbrl.parameters = fo.typedParameters()
                    ValidateFormula.validate(modelXbrl, compileOnly=(options.formulaAction != "run"))
                    self.addToLog(format_string(self.modelManager.locale, 
                                                _("formula validation and execution in %.2f secs")
                                                if options.formulaAction == "run"
                                                else _("formula validation only in %.2f secs"), 
                                                time.time() - startedAt),
                                                messageCode="info", file=self.entrypointFile)
                    

                if options.testReport:
                    ViewFileTests.viewTests(self.modelManager.modelXbrl, options.testReport, options.testReportCols)
                    
                if options.rssReport:
                    ViewFileRssFeed.viewRssFeed(self.modelManager.modelXbrl, options.rssReport, options.rssReportCols)
                    
                if options.DTSFile:
                    ViewFileDTS.viewDTS(modelXbrl, options.DTSFile)
                if options.factsFile:
                    ViewFileFactList.viewFacts(modelXbrl, options.factsFile, labelrole=options.labelRole, lang=options.labelLang, cols=options.factListCols)
                if options.factTableFile:
                    ViewFileFactTable.viewFacts(modelXbrl, options.factTableFile, labelrole=options.labelRole, lang=options.labelLang)
                if options.conceptsFile:
                    ViewFileConcepts.viewConcepts(modelXbrl, options.conceptsFile, labelrole=options.labelRole, lang=options.labelLang)
                if options.preFile:
                    ViewFileRelationshipSet.viewRelationshipSet(modelXbrl, options.preFile, "Presentation Linkbase", "http://www.xbrl.org/2003/arcrole/parent-child", labelrole=options.labelRole, lang=options.labelLang)
                if options.calFile:
                    ViewFileRelationshipSet.viewRelationshipSet(modelXbrl, options.calFile, "Calculation Linkbase", "http://www.xbrl.org/2003/arcrole/summation-item", labelrole=options.labelRole, lang=options.labelLang)
                if options.dimFile:
                    ViewFileRelationshipSet.viewRelationshipSet(modelXbrl, options.dimFile, "Dimensions", "XBRL-dimensions", labelrole=options.labelRole, lang=options.labelLang)
                if options.formulaeFile:
                    ViewFileFormulae.viewFormulae(modelXbrl, options.formulaeFile, "Formulae", lang=options.labelLang)
                if options.viewArcrole and options.viewFile:
                    ViewFileRelationshipSet.viewRelationshipSet(modelXbrl, options.viewFile, os.path.basename(options.viewArcrole), options.viewArcrole, labelrole=options.labelRole, lang=options.labelLang)
                for pluginXbrlMethod in pluginClassMethods("CntlrCmdLine.Xbrl.Run"):
                    pluginXbrlMethod(self, options, modelXbrl)
                                        
            except (IOError, EnvironmentError) as err:
                self.addToLog(_("[IOError] Failed to save output:\n {0}").format(err))
                success = False
            except Exception as err:
                self.addToLog(_("[Exception] Failed to complete request: \n{0} \n{1}").format(
                            err,
                            traceback.format_tb(sys.exc_info()[2])))
                success = False
        if modelXbrl:
            modelXbrl.profileStat(_("total"), time.time() - firstStartedAt)
            if options.collectProfileStats and modelXbrl:
                modelXbrl.logProfileStats()
            if not options.keepOpen:
                if modelDiffReport:
                    self.modelManager.close(modelDiffReport)
                elif modelXbrl:
                    self.modelManager.close(modelXbrl)
        self.username = self.password = None #dereference password
        return success
开发者ID:dknochen,项目名称:Arelle,代码行数:101,代码来源:CntlrCmdLine.py

示例13: createTargetInstance

def createTargetInstance(modelXbrl, targetUrl, targetDocumentSchemaRefs, filingFiles, baseXmlLang=None, defaultXmlLang=None):
    targetInstance = ModelXbrl.create(modelXbrl.modelManager,
                                      newDocumentType=Type.INSTANCE,
                                      url=targetUrl,
                                      schemaRefs=targetDocumentSchemaRefs,
                                      isEntry=True,
                                      discover=False) # don't attempt to load DTS
    if baseXmlLang:
        targetInstance.modelDocument.xmlRootElement.set("{http://www.w3.org/XML/1998/namespace}lang", baseXmlLang)
        if defaultXmlLang is None:
            defaultXmlLang = baseXmlLang # allows facts/footnotes to override baseXmlLang
    ValidateXbrlDimensions.loadDimensionDefaults(targetInstance) # need dimension defaults 
    # roleRef and arcroleRef (of each inline document)
    for sourceRefs in (modelXbrl.targetRoleRefs, modelXbrl.targetArcroleRefs):
        for roleRefElt in sourceRefs.values():
            addChild(targetInstance.modelDocument.xmlRootElement, roleRefElt.qname,
                     attributes=roleRefElt.items())
    
    # contexts
    for context in sorted(modelXbrl.contexts.values(), key=lambda c: c.objectIndex): # contexts may come from multiple IXDS files
        ignore = targetInstance.createContext(context.entityIdentifier[0],
                                               context.entityIdentifier[1],
                                               'instant' if context.isInstantPeriod else
                                               'duration' if context.isStartEndPeriod
                                               else 'forever',
                                               context.startDatetime,
                                               context.endDatetime,
                                               None,
                                               context.qnameDims, [], [],
                                               id=context.id)
    for unit in sorted(modelXbrl.units.values(), key=lambda u: u.objectIndex): # units may come from multiple IXDS files
        measures = unit.measures
        ignore = targetInstance.createUnit(measures[0], measures[1], id=unit.id)

    modelXbrl.modelManager.showStatus(_("Creating and validating facts"))
    newFactForOldObjId = {}
    def createFacts(facts, parent):
        for fact in facts:
            if fact.isItem: # HF does not de-duplicate, which is currently-desired behavior
                attrs = {"contextRef": fact.contextID}
                if fact.id:
                    attrs["id"] = fact.id
                if fact.isNumeric:
                    attrs["unitRef"] = fact.unitID
                    if fact.get("decimals"):
                        attrs["decimals"] = fact.get("decimals")
                    if fact.get("precision"):
                        attrs["precision"] = fact.get("precision")
                if fact.isNil:
                    attrs[XbrlConst.qnXsiNil] = "true"
                    text = None
                else:
                    text = fact.xValue if fact.xValid else fact.textValue
                    if fact.concept is not None and fact.concept.baseXsdType in ("string", "normalizedString"): # default
                        xmlLang = fact.xmlLang
                        if xmlLang is not None and xmlLang != defaultXmlLang:
                            attrs["{http://www.w3.org/XML/1998/namespace}lang"] = xmlLang
                newFact = targetInstance.createFact(fact.qname, attributes=attrs, text=text, parent=parent)
                # if fact.isFraction, create numerator and denominator
                newFactForOldObjId[fact.objectIndex] = newFact
                if filingFiles is not None and fact.concept is not None and fact.concept.isTextBlock:
                    # check for img and other filing references so that referenced files are included in the zip.
                    for xmltext in [text] + CDATApattern.findall(text):
                        try:
                            for elt in XML("<body>\n{0}\n</body>\n".format(xmltext)).iter():
                                addLocallyReferencedFile(elt, filingFiles)
                        except (XMLSyntaxError, UnicodeDecodeError):
                            pass  # TODO: Why ignore UnicodeDecodeError?
            elif fact.isTuple:
                newTuple = targetInstance.createFact(fact.qname, parent=parent)
                newFactForOldObjId[fact.objectIndex] = newTuple
                createFacts(fact.modelTupleFacts, newTuple)
                
    createFacts(modelXbrl.facts, None)
    modelXbrl.modelManager.showStatus(_("Creating and validating footnotes and relationships"))
    HREF = "{http://www.w3.org/1999/xlink}href"
    footnoteLinks = defaultdict(list)
    footnoteIdCount = {}
    for linkKey, linkPrototypes in modelXbrl.baseSets.items():
        arcrole, linkrole, linkqname, arcqname = linkKey
        if (linkrole and linkqname and arcqname and  # fully specified roles
            arcrole != "XBRL-footnotes" and
            any(lP.modelDocument.type == Type.INLINEXBRL for lP in linkPrototypes)):
            for linkPrototype in linkPrototypes:
                if linkPrototype not in footnoteLinks[linkrole]:
                    footnoteLinks[linkrole].append(linkPrototype)
    for linkrole in sorted(footnoteLinks.keys()):
        for linkPrototype in footnoteLinks[linkrole]:
            newLink = addChild(targetInstance.modelDocument.xmlRootElement, 
                               linkPrototype.qname, 
                               attributes=linkPrototype.attributes)
            for linkChild in linkPrototype:
                attributes = linkChild.attributes
                if isinstance(linkChild, LocPrototype):
                    if HREF not in linkChild.attributes:
                        linkChild.attributes[HREF] = \
                        "#" + elementFragmentIdentifier(newFactForOldObjId[linkChild.dereference().objectIndex])
                    addChild(newLink, linkChild.qname, 
                             attributes=attributes)
                elif isinstance(linkChild, ArcPrototype):
#.........这里部分代码省略.........
开发者ID:Arelle,项目名称:Arelle,代码行数:101,代码来源:inlineXbrlDocumentSet.py

示例14: loadXbrlFromDB

    def loadXbrlFromDB(self, loadDBsaveToFile):
        # load from database
        modelXbrl = self.modelXbrl
        
        # find instance in DB
        instanceURI = os.path.basename(loadDBsaveToFile)
        results = self.execute("SELECT InstanceID, ModuleID, EntityScheme, EntityIdentifier, PeriodEndDateOrInstant"
                               " FROM dInstance WHERE FileName = '{}'"
                               .format(instanceURI))
        instanceId = moduleId = None
        for instanceId, moduleId, entScheme, entId, datePerEnd in results:
            break

        # find module in DB        
        results = self.execute("SELECT XbrlSchemaRef FROM mModule WHERE ModuleID = {}".format(moduleId))
        xbrlSchemaRef = None
        for result in results:
            xbrlSchemaRef = result[0]
            break
        
        if not instanceId or not xbrlSchemaRef:
            raise XPDBException("sqlDB:MissingDTS",
                    _("The instance and module were not found for %(instanceURI)"),
                    instanceURI = instanceURI) 
            
        if modelXbrl.skipDTS:
            # find prefixes and namespaces in DB
            results = self.execute("SELECT * FROM [vwGetNamespacesPrefixes]")            
            dpmPrefixedNamespaces = dict((prefix, namespace)
                                         for owner, prefix, namespace in results)
            
        # create the instance document and resulting filing
        modelXbrl.blockDpmDBrecursion = True
        modelXbrl.modelDocument = createModelDocument(modelXbrl, 
                                                      Type.INSTANCE,
                                                      loadDBsaveToFile,
                                                      schemaRefs=[xbrlSchemaRef],
                                                      isEntry=True)
        ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl) # needs dimension defaults 
        
        addProcessingInstruction(modelXbrl.modelDocument.xmlRootElement, 
                                 'xbrl-streamable-instance', 
                                 'version="1.0" contextBuffer="1"')

        # add roleRef and arcroleRef (e.g. for footnotes, if any, see inlineXbrlDocue)
        
        # filing indicator code IDs
        # get filing indicators
        results = self.execute("SELECT mToT.TemplateOrTableCode "
                               "  FROM dFilingIndicator dFI, mTemplateOrTable mToT "
                               "  WHERE dFI.InstanceID = {} AND mTot.TemplateOrTableID = dFI.BusinessTemplateID"
                               .format(instanceId))
        filingIndicatorCodes = [code[0] for code in results]
        
        if filingIndicatorCodes:
            modelXbrl.createContext(entScheme,
                        entId,
                        'instant',
                        None,
                        datePerEnd,
                        None, # no dimensional validity checking (like formula does)
                        {}, [], [],
                        id='c')
            filingIndicatorsTuple = modelXbrl.createFact(qnFindFilingIndicators)
            for filingIndicatorCode in filingIndicatorCodes:
                modelXbrl.createFact(qnFindFilingIndicator, 
                                     parent=filingIndicatorsTuple,
                                     attributes={"contextRef": "c"}, 
                                     text=filingIndicatorCode)

        
        # facts in this instance
        factsTbl = self.execute("SELECT DataPointSignature, DataPointSignatureWithValuesForWildcards,"
                                " Unit, Decimals, NumericValue, DateTimeValue, BooleanValue, TextValue "
                                "FROM dFact WHERE InstanceID = {} "
                                "ORDER BY substr(CASE WHEN DataPointSignatureWithValuesForWildcards IS NULL "
                                "                          THEN DataPointSignature"
                                "                          ELSE DataPointSignatureWithValuesForWildcards"
                                "                END, instr(DataPointSignature,'|') + 1)"
                                .format(instanceId))
        
        # results tuple: factId, dec, varId, dpKey, entId, datePerEnd, unit, numVal, dateVal, boolVal, textVal

        # get typed dimension values
        prefixedNamespaces = modelXbrl.prefixedNamespaces
        prefixedNamespaces["iso4217"] = XbrlConst.iso4217
        if modelXbrl.skipDTS:
            prefixedNamespaces.update(dpmPrefixedNamespaces) # for skipDTS this is always needed
        
        cntxTbl = {} # index by d
        unitTbl = {}
        
        def typedDimElt(s):
            # add xmlns into s for known qnames
            tag, angleBrkt, rest = s[1:].partition('>')
            text, angleBrkt, rest = rest.partition("<")
            qn = qname(tag, prefixedNamespaces)
            # a modelObject xml element is needed for all of the instance functions to manage the typed dim
            return addChild(modelXbrl.modelDocument, qn, text=text, appendChild=False)
        
#.........这里部分代码省略.........
开发者ID:vincejolivet,项目名称:Arelle,代码行数:101,代码来源:XbrlDpmSqlDB.py

示例15: validate

def validate(logMessage, sphinxContext):
    modelXbrl = sphinxContext.modelXbrl
    hasDTS = modelXbrl is not None
    
    
    if hasDTS:
        # if no formulas loaded, set
        if not hasattr(modelXbrl, "modelFormulaEqualityDefinitions"):
            modelXbrl.modelFormulaEqualityDefinitions = {}
    
        import logging
        initialErrorCount = modelXbrl.logCount.get(logging.getLevelName('ERROR'), 0)

        # must also have default dimensions loaded
        from arelle import ValidateXbrlDimensions
        ValidateXbrlDimensions.loadDimensionDefaults(modelXbrl)
        
    sphinxContext.ruleBasePreconditionNodes = []
    sphinxContext.preconditionNodes = {}
    
    # accumulate definitions
    for prog in sphinxContext.sphinxProgs:
        for node in prog:
            if isinstance(node, astRuleBasePrecondition):
                sphinxContext.ruleBasePreconditionNodes.append(node)
            elif isinstance(node, astPreconditionDeclaration):
                sphinxContext.preconditionNodes[node.name] = node    
            elif isinstance(node, astFunctionDeclaration):
                sphinxContext.functions[node.name] = node
            elif isinstance(node, astConstant):
                sphinxContext.constants[node.constantName] = node
                node.value = None   # compute dynamically on first reference
                if node.tagName:
                    sphinxContext.taggedConstants[node.tagName] = node

    # check references            
    def checkNodes(nodes, inMacro=False):
        if not nodes: return
        for node in nodes:
            if node is None:
                continue
            elif isinstance(node, (list,set)):
                checkNodes(node, inMacro)
            elif isinstance(node, astPreconditionReference):
                for name in node.names:
                    if name not in sphinxContext.preconditionNodes:
                        logMessage("ERROR", "sphinxCompiler:preconditionReferenceI",
                            _("Precondition reference is not defined %(name)s"),
                            sourceFileLine=node.sourceFileLine,
                            name=name)
            elif isinstance(node, (astFormulaRule, astReportRule, astValidationRule)):
                checkNodes((node.precondition, node.severity, 
                            node.variableAssignments, 
                            node.expr, node.message), inMacro)
                sphinxContext.rules.append(node)
                if node.severity:
                    severity = node.severity
                    if isinstance(severity, astFunctionReference):
                        severity = severity.name
                    if (severity not in ("error", "warning", "info") and
                        (isinstance(node, astFormulaRule) and severity not in sphinxContext.functions)):
                        logMessage("ERROR", "sphinxCompiler:ruleSeverity",
                            _("Rule %(name)s severity is not recognized: %(severity)s"),
                            sourceFileLine=node.sourceFileLine,
                            name=node.name,
                            severity=node.severity)
                if isinstance(node, astFormulaRule) and not hasFormulaOp(node):
                    logMessage("ERROR", "sphinxCompiler:formulaSyntax",
                        _("Formula %(name)s missing \":=\" operation"),
                        sourceFileLine=node.sourceFileLine,
                        name=node.name)
            elif isinstance(node, astHyperspaceExpression) and hasDTS:
                # check axes
                for axis in node.axes:
                    if isinstance(axis.aspect, QName):
                        concept = modelXbrl.qnameConcepts.get(axis)
                        if concept is None or not concept.isDimensionItem:
                            logMessage("ERROR", "sphinxCompiler:axisNotDimension",
                                _("Axis is not a dimension in the DTS %(qname)s"),
                                sourceFileLine=node.sourceFileLine,
                                qname=axis)
                        elif axis not in sphinxContext.dimensionIsExplicit:
                            sphinxContext.dimensionIsExplicit[axis] = concept.isExplicitDimension
                    elif isinstance(axis.aspect, astNode):
                        if not inMacro:
                            logMessage("ERROR", "sphinxCompiler:axisDisallowed",
                                _("Hypercube axis aspect not static %(aspect)s"),
                                sourceFileLine=node.sourceFileLine,
                                aspect=axis.aspect)
                    elif (axis.aspect not in {"unit", "segment", "scenario"} and
                        isinstance(axis.restriction, (list, tuple))):
                        for restrictionValue in axis.restriction:
                            if isinstance(restrictionValue, QName) and not restrictionValue in modelXbrl.qnameConcepts: 
                                logMessage("ERROR", "sphinxCompiler:axisNotDimension",
                                    _("Hypercube value not in the DTS %(qname)s"),
                                    sourceFileLine=node.sourceFileLine,
                                    qname=restrictionValue)
                        checkNodes((axis.whereExpr,), inMacro)
            elif isinstance(node, astWith):
                node.axes = {}
#.........这里部分代码省略.........
开发者ID:DaveInga,项目名称:Arelle,代码行数:101,代码来源:SphinxValidator.py


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