Пример #1
0
 def selectLocally(self):
     choices = [] # list of tuple of (file name, description)
     def sortOrder(key):
         return {"EdgarRenderer": "1",
                 "validate": "2",
                 "xbrlDB": "3"}.get(key, "4") + key.lower()
     def selectChoices(dir, indent=""):
         dirHasEntries = False
         for f in sorted(os.listdir(dir), key=sortOrder):
             if f not in (".", "..", "__pycache__", "__init__.py"):
                 fPath = os.path.join(dir, f)
                 fPkgInit = os.path.join(fPath, "__init__.py")
                 dirInsertPoint = len(choices)
                 moduleInfo = None
                 if ((os.path.isdir(fPath) and os.path.exists(fPkgInit)) or
                     ((os.path.isfile(fPath) and f.endswith(".py")))):
                     moduleInfo = PluginManager.moduleModuleInfo(fPath)
                     if moduleInfo:
                         choices.append((indent + f, 
                                         "name: {}\ndescription: {}\n version {}".format(
                                                     moduleInfo["name"],
                                                     moduleInfo["description"],
                                                     moduleInfo.get("version")), 
                                         fPath, moduleInfo["name"], moduleInfo.get("version"), moduleInfo["description"]))
                         dirHasEntries = True
                 if os.path.isdir(fPath) and f not in ("DQC_US_Rules",):
                     if selectChoices(fPath, indent=indent + "   ") and not moduleInfo:
                         choices.insert(dirInsertPoint, (indent + f,None,None,None,None,None))
         return dirHasEntries
     selectChoices(self.cntlr.pluginDir)
     selectedPath = DialogOpenArchive.selectPlugin(self, choices)
     if selectedPath:
         moduleInfo = PluginManager.moduleModuleInfo(selectedPath)
         self.loadFoundModuleInfo(moduleInfo, selectedPath)
Пример #2
0
 def selectFromRegistry(self):
     choices = [] # list of tuple of (file name, description)
     uiLang = (self.cntlr.config.get("userInterfaceLangOverride") or self.cntlr.modelManager.defaultLang or "en")[:2]
     def langLabel(labels):
         for _lang in uiLang, "en":
             for label in labels:
                 if label["Language"].startswith(_lang):
                      return label["Label"]
         for label in labels:
              return label["Label"]
         return ""
         
     with open(self.webCache.getfilename("https://taxonomies.xbrl.org/api/v0/taxonomy", reload=True), 'r', errors='replace') as fh:
         regPkgs = json.load(fh) # always reload
     for pkgTxmy in regPkgs.get("taxonomies", []):
         _name = langLabel(pkgTxmy["Name"])
         _description = langLabel(pkgTxmy.get("Description"))
         _version = pkgTxmy.get("Version")
         _license = pkgTxmy.get("License",{}).get("Name")
         _url = pkgTxmy.get("Links",{}).get("AuthoritativeURL")
         choices.append((_name,
                         "name: {}\ndescription: {}\nversion: {}\nlicense: {}".format(
                                 _name, _description, _version, _license),
                         _url,  _version, _description, _license))
     self.loadPackageUrl(DialogOpenArchive.selectPackage(self, choices))                                    
Пример #3
0
def runOpenInlineDocumentSetMenuCommand(cntlr,
                                        runInBackground=False,
                                        saveTargetFiling=False):
    filenames = cntlr.uiFileDialog(
        "open",
        multiple=True,
        title=_("arelle - Multi-open inline XBRL file(s)"),
        initialdir=cntlr.config.setdefault("fileOpenDir", "."),
        filetypes=[(_("XBRL files"), "*.*")],
        defaultextension=".xbrl")
    if os.sep == "\\":
        filenames = [f.replace("/", "\\") for f in filenames]

    if not filenames:
        filename = ""
    elif len(filenames) == 1 and (filenames[0].endswith(".zip")
                                  or filenames[0].endswith(".tar.gz")):
        # get archive file names
        from arelle.FileSource import openFileSource
        filesource = openFileSource(filenames[0], cntlr)
        if filesource.isArchive:
            from arelle import DialogOpenArchive
            archiveEntries = DialogOpenArchive.askArchiveFile(cntlr,
                                                              filesource,
                                                              multiselect=True)
            if archiveEntries:
                ixdsFirstFile = archiveEntries[0]
                _archiveFilenameParts = archiveFilenameParts(ixdsFirstFile)
                if _archiveFilenameParts is not None:
                    ixdsDir = _archiveFilenameParts[
                        0]  # it's a zip or package, use zip file name as head of ixds
                else:
                    ixdsDir = os.path.dirname(ixdsFirstFile)
                docsetSurrogatePath = os.path.join(ixdsDir, IXDS_SURROGATE)
                filename = docsetSurrogatePath + IXDS_DOC_SEPARATOR.join(
                    archiveEntries)
            else:
                filename = None
        filesource.close()
    elif len(filenames) >= MINIMUM_IXDS_DOC_COUNT:
        ixdsFirstFile = filenames[0]
        _archiveFilenameParts = archiveFilenameParts(ixdsFirstFile)
        if _archiveFilenameParts is not None:
            ixdsDir = _archiveFilenameParts[
                0]  # it's a zip or package, use zip file name as head of ixds
        else:
            ixdsDir = os.path.dirname(ixdsFirstFile)
        docsetSurrogatePath = os.path.join(ixdsDir, IXDS_SURROGATE)
        filename = docsetSurrogatePath + IXDS_DOC_SEPARATOR.join(filenames)
    else:
        filename = filenames[0]
    if filename is not None:
        cntlr.fileOpenFile(filename)
Пример #4
0
 def webOpen(self, *ignore):
     if not self.okayToContinue():
         return
     url = DialogURL.askURL(self.parent)
     if url:
         self.updateFileHistory(url, False)
         filesource = openFileSource(url,self)
         if filesource.isArchive and not filesource.selection: # or filesource.isRss:
             from arelle import DialogOpenArchive
             url = DialogOpenArchive.askArchiveFile(self, filesource)
         self.updateFileHistory(url, False)
         thread = threading.Thread(target=lambda: self.backgroundLoadXbrl(filesource,False))
         thread.daemon = True
         thread.start()
Пример #5
0
def runOpenInlineDocumentSetMenuCommand(cntlr,
                                        filenames,
                                        runInBackground=False,
                                        saveTargetFiling=False):
    if os.sep == "\\":
        filenames = [f.replace("/", "\\") for f in filenames]

    if not filenames:
        filename = ""
    elif len(filenames) == 1 and any(filenames[0].endswith(s)
                                     for s in archiveFilenameSuffixes):
        # get archive file names
        from arelle.FileSource import openFileSource
        filesource = openFileSource(filenames[0], cntlr)
        if filesource.isArchive:
            from arelle import DialogOpenArchive
            archiveEntries = DialogOpenArchive.askArchiveFile(cntlr,
                                                              filesource,
                                                              multiselect=True)
            if archiveEntries:
                ixdsFirstFile = archiveEntries[0]
                _archiveFilenameParts = archiveFilenameParts(ixdsFirstFile)
                if _archiveFilenameParts is not None:
                    ixdsDir = _archiveFilenameParts[
                        0]  # it's a zip or package, use zip file name as head of ixds
                else:
                    ixdsDir = os.path.dirname(ixdsFirstFile)
                docsetSurrogatePath = os.path.join(ixdsDir, IXDS_SURROGATE)
                filename = docsetSurrogatePath + IXDS_DOC_SEPARATOR.join(
                    archiveEntries)
            else:
                filename = None
        filesource.close()
    elif len(filenames) >= MINIMUM_IXDS_DOC_COUNT:
        ixdsFirstFile = filenames[0]
        _archiveFilenameParts = archiveFilenameParts(ixdsFirstFile)
        if _archiveFilenameParts is not None:
            ixdsDir = _archiveFilenameParts[
                0]  # it's a zip or package, use zip file name as head of ixds
        else:
            ixdsDir = os.path.dirname(ixdsFirstFile)
        docsetSurrogatePath = os.path.join(ixdsDir, IXDS_SURROGATE)
        filename = docsetSurrogatePath + IXDS_DOC_SEPARATOR.join(filenames)
    else:
        filename = filenames[0]
    if filename is not None:
        cntlr.fileOpenFile(filename)
Пример #6
0
 def fileOpenFile(self, filename, importToDTS=False):
     if filename:
         filesource = None
         # check for archive files
         filesource = openFileSource(filename,self)
         if filesource.isArchive and not filesource.selection: # or filesource.isRss:
             from arelle import DialogOpenArchive
             filename = DialogOpenArchive.askArchiveFile(self, filesource)
             
     if filename:
         if importToDTS:
             self.config["importOpenDir"] = os.path.dirname(filename)
         else:
             if not filename.startswith("http://"):
                 self.config["fileOpenDir"] = os.path.dirname(filename)
         self.updateFileHistory(filename, importToDTS)
         thread = threading.Thread(target=lambda: self.backgroundLoadXbrl(filesource,importToDTS))
         thread.daemon = True
         thread.start()
Пример #7
0
    def selectFromRegistry(self):
        choices = []  # list of tuple of (file name, description)
        uiLang = (self.cntlr.config.get("userInterfaceLangOverride")
                  or self.cntlr.modelManager.defaultLang or "en")[:2]

        def langLabel(labels):
            if not labels:
                return ""
            for _lang in uiLang, "en":
                for label in labels:
                    if label["Language"].startswith(_lang):
                        return label["Label"]
            for label in labels:
                return label["Label"]
            return ""

        try:
            with open(self.webCache.getfilename(STANDARD_PACKAGES_URL,
                                                reload=True),
                      'r',
                      errors='replace') as fh:
                regPkgs = json.load(fh)  # always reload
            for pkgTxmy in regPkgs.get("taxonomies", []):
                _name = langLabel(pkgTxmy["Name"])
                _description = langLabel(pkgTxmy.get("Description"))
                _version = pkgTxmy.get("Version")
                _license = pkgTxmy.get("License", {}).get("Name")
                _url = pkgTxmy.get("Links", {}).get("AuthoritativeURL")
                choices.append(
                    (_name,
                     "name: {}\ndescription: {}\nversion: {}\nlicense: {}".
                     format(_name, _description, _version,
                            _license), _url, _version, _description, _license))
            self.loadPackageUrl(DialogOpenArchive.selectPackage(self, choices))
        except (TypeError) as err:
            messagebox.showwarning(
                _("Unable to retrieve standard packages.  "),
                _("Standard packages URL is not accessible, please check if online:\n\n{0}."
                  ).format(STANDARD_PACKAGES_URL),
                parent=self)
Пример #8
0
 def selectDisclosureSystem(self, *args):
     from arelle import DialogOpenArchive
     self.config["disclosureSystem"] = DialogOpenArchive.selectDisclosureSystem(self, self.modelManager.disclosureSystem)
     self.saveConfig()
     self.setValidateTooltipText()