Exemple #1
0
 def __init__(self, modelXbrl):
     self.isInline = modelXbrl.modelDocument.type == ModelDocument.Type.INLINEXBRL
     self.url = modelXbrl.modelDocument.uri
     self.basename = modelXbrl.modelDocument.basename
     self.filepath = modelXbrl.modelDocument.filepath
     for attrName in Report.REPORT_ATTRS:
         setattr(self, self.lc(attrName), None)
     self.instanceName = modelXbrl.modelDocument.basename
     for f in modelXbrl.facts:
         cntx = f.context
         if cntx is not None and cntx.isStartEndPeriod and not cntx.hasSegment:
             if f.qname is not None and f.qname.localName in Report.REPORT_ATTRS and f.xValue:
                 setattr(self, self.lc(f.qname.localName), f.xValue)
     self.reportedFiles = {modelXbrl.modelDocument.basename} | referencedFiles(modelXbrl)
     self.renderedFiles = set()
     self.hasUsGaapTaxonomy = False
     sourceDir = os.path.dirname(modelXbrl.modelDocument.filepath)
     # add referenced files that are xbrl-referenced local documents
     refDocUris = set()
     def addRefDocs(doc):
         for refDoc in doc.referencesDocument.keys():
             _file = refDoc.filepath
             if refDoc.uri not in refDocUris:
                 refDocUris.add(refDoc.uri)
                 if refDoc.filepath and refDoc.filepath.startswith(sourceDir):
                     self.reportedFiles.add(refDoc.filepath[len(sourceDir)+1:]) # add file name within source directory
                 addRefDocs(refDoc)
             if refDoc.type == ModelDocument.Type.SCHEMA and refDoc.targetNamespace:
                 nsAuthority = authority(refDoc.targetNamespace, includeScheme=False)
                 nsPath = refDoc.targetNamespace.split('/')
                 if len(nsPath) > 2:
                     if nsAuthority in ("fasb.org", "xbrl.us") and nsPath[-2] == "us-gaap":
                         self.hasUsGaapTaxonomy = True
     addRefDocs(modelXbrl.modelDocument)
Exemple #2
0
    def __init__(self, modelXbrl):
        self.isInline = modelXbrl.modelDocument.type in (
            Type.INLINEXBRL, Type.INLINEXBRLDOCUMENTSET)
        self.url = modelXbrl.modelDocument.uri
        self.reportedFiles = set()
        if modelXbrl.modelDocument.type == Type.INLINEXBRLDOCUMENTSET:
            self.basenames = []
            self.filepaths = []
            for ixDoc in sorted(
                    modelXbrl.modelDocument.referencesDocument.keys(),
                    key=lambda d: d.objectIndex):  # preserve order
                if ixDoc.type == Type.INLINEXBRL:
                    self.basenames.append(ixDoc.basename)
                    self.filepaths.append(ixDoc.filepath)
                    self.reportedFiles.add(ixDoc.basename)
        else:
            self.basenames = [modelXbrl.modelDocument.basename]
            self.filepaths = [modelXbrl.modelDocument.filepath]
            self.reportedFiles.add(modelXbrl.modelDocument.basename)
        for attrName in Report.REPORT_ATTRS:
            setattr(self, self.lc(attrName), None)
        self.instanceName = self.basenames[0]
        for f in modelXbrl.facts:
            cntx = f.context
            if cntx is not None and cntx.isStartEndPeriod and not cntx.hasSegment:
                if f.qname is not None and f.qname.localName in Report.REPORT_ATTRS and f.xValue:
                    setattr(self, self.lc(f.qname.localName), f.xValue)
        self.reportedFiles |= referencedFiles(modelXbrl)
        self.renderedFiles = set()
        self.hasUsGaapTaxonomy = False
        sourceDir = os.path.dirname(modelXbrl.modelDocument.filepath)
        # add referenced files that are xbrl-referenced local documents
        refDocUris = set()

        def addRefDocs(doc):
            if doc.type == Type.INLINEXBRLDOCUMENTSET:
                for ixDoc in doc.referencesDocument.keys():
                    if ixDoc.type == Type.INLINEXBRL:
                        addRefDocs(ixDoc)
                return
            for refDoc in doc.referencesDocument.keys():
                _file = refDoc.filepath
                if refDoc.uri not in refDocUris:
                    refDocUris.add(refDoc.uri)
                    if refDoc.filepath and refDoc.filepath.startswith(
                            sourceDir):
                        self.reportedFiles.add(
                            refDoc.filepath[len(sourceDir) + 1:]
                        )  # add file name within source directory
                    addRefDocs(refDoc)
                if refDoc.type == Type.SCHEMA and refDoc.targetNamespace:
                    nsAuthority = authority(refDoc.targetNamespace,
                                            includeScheme=False)
                    nsPath = refDoc.targetNamespace.split('/')
                    if len(nsPath) > 2:
                        if nsAuthority in ("fasb.org", "xbrl.us"
                                           ) and nsPath[-2] == "us-gaap":
                            self.hasUsGaapTaxonomy = True

        addRefDocs(modelXbrl.modelDocument)