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


Python arelle.PackageManager类代码示例

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


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

示例1: packageRemove

 def packageRemove(self):
     if 0 <= self.selectedPackageIndex < len(self.packagesConfig["packages"]):
         packageInfo = self.packagesConfig["packages"][self.selectedPackageIndex]
         self.removePackageInfo(packageInfo["name"], packageInfo["version"])
         self.packagesConfigChanged = True
         PackageManager.rebuildRemappings()
         self.loadTreeViews()
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:7,代码来源:DialogPackageManager.py

示例2: addPackageInfo

 def addPackageInfo(self, packageInfo):
     name = packageInfo["name"]
     version = packageInfo["version"]
     self.removePackageInfo(name, version)  # remove any prior entry for this package
     self.packageNamesWithNewerFileDates.discard(name) # no longer has an update available
     self.packagesConfig["packages"].append(packageInfo)
     PackageManager.rebuildRemappings()
     self.packagesConfigChanged = True
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:8,代码来源:DialogPackageManager.py

示例3: packageMoveDown

 def packageMoveDown(self):
     if 0 <= self.selectedPackageIndex < len(self.packagesConfig["packages"]) - 1:
         packages = self.packagesConfig["packages"]
         packageInfo = packages[self.selectedPackageIndex]
         del packages[self.selectedPackageIndex]
         packages.insert(self.selectedPackageIndex + 1, packageInfo)
         self.packagesConfigChanged = True
         PackageManager.rebuildRemappings()
         self.loadTreeViews()
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:9,代码来源:DialogPackageManager.py

示例4: packageEnable

 def packageEnable(self):
     if 0 <= self.selectedPackageIndex < len(self.packagesConfig["packages"]):
         packageInfo = self.packagesConfig["packages"][self.selectedPackageIndex]
         if self.packageEnableButton['text'] == self.ENABLE:
             packageInfo["status"] = "enabled"
             self.packageEnableButton['text'] = self.DISABLE
         elif self.packageEnableButton['text'] == self.DISABLE:
             packageInfo["status"] = "disabled"
             self.packageEnableButton['text'] = self.ENABLE
         self.packagesConfigChanged = True
         PackageManager.rebuildRemappings()
         self.loadTreeViews()
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:12,代码来源:DialogPackageManager.py

示例5: enableDisableAll

 def enableDisableAll(self, doEnable):
     for iPkg in range(len(self.packagesConfig["packages"])):
         packageInfo = self.packagesConfig["packages"][iPkg]
         if doEnable:
             packageInfo["status"] = "enabled"
             self.packageEnableButton['text'] = self.DISABLE
         else:
             packageInfo["status"] = "disabled"
             self.packageEnableButton['text'] = self.ENABLE
     self.packagesConfigChanged = True
     PackageManager.rebuildRemappings(self.cntlr)
     self.loadTreeViews()
开发者ID:davidjbell,项目名称:Arelle,代码行数:12,代码来源:DialogPackageManager.py

示例6: close

 def close(self, saveConfig=False):
     """Closes the controller and its logger, optionally saving the user preferences configuration
        
        :param saveConfig: save the user preferences configuration
        :type saveConfig: bool
     """
     PluginManager.save(self)
     PackageManager.save(self)
     if saveConfig:
         self.saveConfig()
     if self.logger is not None:
         try:
             self.logHandler.close()
         except Exception: # fails on some earlier pythons (3.1)
             pass
开发者ID:irjudson,项目名称:Arelle,代码行数:15,代码来源:Cntlr.py

示例7: packageReload

 def packageReload(self):
     if 0 <= self.selectedPackageIndex < len(self.packagesConfig["packages"]):
         packageInfo = self.packagesConfig["packages"][self.selectedPackageIndex]
         url = packageInfo.get("URL")
         if url:
             packageInfo = PackageManager.packageInfo(url, reload=True, packageManifestName=packageInfo.get("manifestName"))
             if packageInfo:
                 self.addPackageInfo(packageInfo)
                 PackageManager.rebuildRemappings()
                 self.loadTreeViews()
                 self.cntlr.showStatus(_("{0} reloaded").format(packageInfo.get("name")), clearAfter=5000)
             else:
                 messagebox.showwarning(_("Package error"),
                                        _("File or package cannot be reloaded: \n\n{0}")
                                        .format(url),
                                        parent=self)
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:16,代码来源:DialogPackageManager.py

示例8: func_json_data

def func_json_data(xule_context, *args):
    """Read a json file/url.
    
    Arguments:
        file_url (string or url)

    Returns a dictionary/list of the json data.
    """
    
    file_url = args[0]

    if file_url.type not in ('string', 'uri'):
        raise XuleProcessingError(_("The file url argument of the json-dta() function must be a string or uri, found '{}'.".format(file_url.value)), xule_context)

    from arelle import PackageManager
    mapped_file_url = PackageManager.mappedUrl(file_url.value)

    # Using the FileSource object in arelle. This will open the file and handle taxonomy package mappings.
    from arelle import FileSource
    file_source = FileSource.openFileSource(file_url.value, xule_context.global_context.cntlr)
    file = file_source.file(file_url.value, binary=True)
    # file is  tuple of one item as a BytesIO stream. Since this is in bytes, it needs to be converted to text via a decoder.
    # Assuming the file is in utf-8. 
    data_source = [x.decode('utf-8') for x in file[0].readlines()]
    try:
        json_source = json.loads(''.join(data_source))
    #except JSONDecodeError:
    except ValueError:
        raise XuleProcessingError(_("The file '{}' is not a valid JSON file.".format(file_url.value)), xule_context)
    
    x = xv.system_collection_to_xule(json_source, xule_context)
    return xv.system_collection_to_xule(json_source, xule_context)
开发者ID:davidtauriello,项目名称:dqc_us_rules,代码行数:32,代码来源:XuleFunctions.py

示例9: backgroundCheckForUpdates

def backgroundCheckForUpdates(cntlr):
    cntlr.showStatus(_("Checking for updates to packages")) # clear web loading status
    packageNamesWithNewerFileDates = PackageManager.packageNamesWithNewerFileDates()
    if packageNamesWithNewerFileDates:
        cntlr.showStatus(_("Updates are available for these packages: {0}")
                              .format(', '.join(packageNamesWithNewerFileDates)), clearAfter=5000)
    else:
        cntlr.showStatus(_("No updates found for packages."), clearAfter=5000)
    time.sleep(0.1) # Mac locks up without this, may be needed for empty ui queue? 
    cntlr.uiThreadQueue.put((DialogPackageManager, [cntlr, packageNamesWithNewerFileDates]))
开发者ID:JagdishIdhate,项目名称:Arelle,代码行数:10,代码来源:DialogPackageManager.py

示例10: openFileStream

def openFileStream(cntlr, filepath, mode='r', encoding=None):
    if PackageManager.isMappedUrl(filepath):
        filepath = PackageManager.mappedUrl(filepath)
    else:
        filepath = cntlr.modelManager.disclosureSystem.mappedUrl(filepath)
    if archiveFilenameParts(filepath): # file is in an archive
        return openFileSource(filepath, cntlr).file(filepath, binary='b' in mode, encoding=encoding)[0]
    if isHttpUrl(filepath) and cntlr:
        _cacheFilepath = cntlr.webCache.getfilename(filepath)
        if _cacheFilepath is None:
            raise IOError(_("Unable to open file: {0}.").format(filepath))
        filepath = _cacheFilepath
    # file path may be server (or memcache) or local file system
    if filepath.startswith(SERVER_WEB_CACHE) and cntlr:
        filestream = None
        cacheKey = filepath[len(SERVER_WEB_CACHE) + 1:].replace("\\","/")
        if cntlr.isGAE: # check if in memcache
            cachedBytes = gaeGet(cacheKey)
            if cachedBytes:
                filestream = io.BytesIO(cachedBytes)
        if filestream is None:
            filestream = io.BytesIO()
            cntlr.webCache.retrieve(cntlr.webCache.cacheFilepathToUrl(filepath),
                                    filestream=filestream)
            if cntlr.isGAE:
                gaeSet(cacheKey, filestream.getvalue())
        if mode.endswith('t') or encoding:
            contents = filestream.getvalue()
            filestream.close()
            filestream = FileNamedStringIO(filepath, contents.decode(encoding or 'utf-8'))
        return filestream
    # local file system
    elif encoding is None and 'b' not in mode:
        openedFileStream = io.open(filepath, mode='rb')
        hdrBytes = openedFileStream.read(512)
        encoding = XmlUtil.encoding(hdrBytes, default=None)
        openedFileStream.close()
        return io.open(filepath, mode=mode, encoding=encoding)
    else:
        # local file system
        return io.open(filepath, mode=mode, encoding=encoding)
开发者ID:namitkewat,项目名称:Arelle,代码行数:41,代码来源:FileSource.py

示例11: findLocally

 def findLocally(self):
     initialdir = self.cntlr.pluginDir # default plugin directory
     if not self.cntlr.isMac: # can't navigate within app easily, always start in default directory
         initialdir = self.cntlr.config.setdefault("packageOpenDir", initialdir)
     filename = self.cntlr.uiFileDialog("open",
                                        owner=self,
                                        title=_("Choose taxonomy package file"),
                                        initialdir=initialdir,
                                        filetypes=[(_("Taxonomy package files (*.zip)"), "*.zip"),
                                                   (_("Manifest (*.taxonomyPackage.xml)"), "*.taxonomyPackage.xml")],
                                        defaultextension=".zip")
     if filename:
         # check if a package is selected (any file in a directory containing an __init__.py
         self.cntlr.config["packageOpenDir"] = os.path.dirname(filename)
         packageInfo = PackageManager.packageInfo(filename)
         self.loadFoundPackageInfo(packageInfo, filename)
开发者ID:GuoHuiChen,项目名称:Arelle,代码行数:16,代码来源:DialogPackageManager.py

示例12: open_package_file

    def open_package_file(self, file_name):
        """Open a taxonomy package in the rule set
        
        :param file_name: the name of the package file in the rule set
        :type file_name: str
        :return: The package information. This is the return from Arelle when activating the package
        """
        package_info = PackageManager.addPackage(self._cntlr, file_name)
        if package_info:
#                     print("Activation of package {0} successful.".format(package_info.get("name")))    
            self._cntlr.addToLog(_("Activation of package {0} successful.").format(package_info.get("name")), 
                          messageCode="info", file=package_info.get("URL"))
        else:
#                     print("Unable to load package \"{}\". ".format(file_name))                
            self._cntlr.addToLog(_("Unable to load package \"%(name)s\". "),
                          messageCode="arelle:packageLoadingError", 
                          level=logging.ERROR) 
        return package_info
开发者ID:allenbross-wf,项目名称:dqc_us_rules,代码行数:18,代码来源:XuleRuleSet.py

示例13: get_packages_info

 def get_packages_info(self):
     """Get a list of taxonomy packages in the rule set
     
     :returns: List of package information. The package information is returned when activating the package in Arelle
     :rtype: list
     """
     results = []
     temp_dir = tempfile.TemporaryDirectory()
     #Using arelle file source object. This will handle files from the web.
     file_object = self._get_rule_set_file_object()
     try:
         with zipfile.ZipFile(file_object, 'r') as zf:
             for package_file_name in zf.namelist():
                 if package_file_name.startswith('packages/'):
                     package_file = zf.extract(package_file_name, temp_dir.name)
                     package_info = PackageManager.addPackage(self._cntlr, package_file)
                     results.append(package_info)
     finally:
         file_object.close()
         
     return results
开发者ID:allenbross-wf,项目名称:dqc_us_rules,代码行数:21,代码来源:XuleRuleSet.py

示例14: open


#.........这里部分代码省略.........
                        str = buf.decode(XmlUtil.encoding(buf))
                        endEncoding = str.index("?>", 0, 128)
                        if endEncoding > 0:
                            str = str[endEncoding+2:]
                        file = io.StringIO(initial_value=str)
                        parser = etree.XMLParser(recover=True, huge_tree=True)
                        self.eisDocument = etree.parse(file, parser=parser)
                        file.close()
                        self.isOpen = True
                    except EnvironmentError as err:
                        self.logError(err)
                        return # provide error message later
                    except etree.LxmlError as err:
                        self.logError(err)
                        return # provide error message later
                
            elif self.isXfd:
                # check first line of file
                file = open(self.basefile, 'rb')
                firstline = file.readline()
                if firstline.startswith(b"application/x-xfdl;content-encoding=\"asc-gzip\""):
                    # file has been gzipped
                    base64input = file.read(-1)
                    file.close();
                    file = None;
    
                    fb = base64.b64decode(base64input)
                    ungzippedBytes = b""
                    totalLenUncompr = 0
                    i = 0
                    while i < len(fb):
                        lenCompr = fb[i + 0] * 256 + fb[i + 1]
                        lenUncomp = fb[i + 2] * 256 + fb[i + 3]
                        lenRead = 0
                        totalLenUncompr += lenUncomp

                        gzchunk = (bytes((31,139,8,0)) + fb[i:i+lenCompr])
                        try:
                            with gzip.GzipFile(fileobj=io.BytesIO(gzchunk)) as gf:
                                while True:
                                    readSize = min(16384, lenUncomp - lenRead)
                                    readBytes = gf.read(size=readSize)
                                    lenRead += len(readBytes)
                                    ungzippedBytes += readBytes
                                    if len(readBytes) == 0 or (lenUncomp - lenRead) <= 0:
                                        break
                        except IOError as err:
                            pass # provide error message later

                        i += lenCompr + 4
                    #for learning the content of xfd file, uncomment this:
                    #with open("c:\\temp\\test.xml", "wb") as fh:
                    #    fh.write(ungzippedBytes)
                    file = io.StringIO(initial_value=ungzippedBytes.decode("utf-8"))
                else:
                    # position to start of file
                    file.seek(0,io.SEEK_SET)
                    
                try:
                    self.xfdDocument = etree.parse(file)
                    file.close()
                    self.isOpen = True
                except EnvironmentError as err:
                    self.logError(err)
                    return # provide error message later
                except etree.LxmlError as err:
                    self.logError(err)
                    return # provide error message later
                
            elif self.isRss:
                try:
                    self.rssDocument = etree.parse(self.basefile)
                    self.isOpen = True
                except EnvironmentError as err:
                    self.logError(err)
                    return # provide error message later
                except etree.LxmlError as err:
                    self.logError(err)
                    return # provide error message later
            
            elif self.isInstalledTaxonomyPackage:
                self.isOpen = True
                # load mappings
                try:
                    metadataFiles = self.taxonomyPackageMetadataFiles
                    if len(metadataFiles) != 1:
                        raise IOError(_("Taxonomy package must contain one and only one metadata file: {0}.")
                                      .format(', '.join(metadataFiles)))
                    # HF: this won't work, see DialogOpenArchive for correct code
                    # not sure if it is used
                    taxonomyPackage = PackageManager.parsePackage(self.cntlr, self.url)
                    fileSourceDir = os.path.dirname(self.baseurl) + os.sep
                    self.mappedPaths = \
                        dict((prefix, 
                              remapping if isHttpUrl(remapping)
                              else (fileSourceDir + remapping.replace("/", os.sep)))
                              for prefix, remapping in taxonomyPackage["remappings"].items())
                except EnvironmentError as err:
                    self.logError(err)
                    return # provide error message later
开发者ID:namitkewat,项目名称:Arelle,代码行数:101,代码来源:FileSource.py

示例15: __init__


#.........这里部分代码省略.........
            impliedAppDir = os.path.join(configHomeDir, "arelle")
            if os.path.exists(impliedAppDir):
                self.userAppDir = impliedAppDir
            elif os.path.exists(os.path.join(configHomeDir, "cache")):
                self.userAppDir = configHomeDir # use the XDG_CONFIG_HOME because cache is already a subdirectory
            else:
                self.userAppDir = impliedAppDir
        if sys.platform == "darwin":
            self.isMac = True
            self.isMSW = False
            if self.hasFileSystem and not configHomeDir:
                self.userAppDir = os.path.expanduser("~") + "/Library/Application Support/Arelle"
            # note that cache is in ~/Library/Caches/Arelle
            self.contextMenuClick = "<Button-2>"
            self.hasClipboard = hasGui  # clipboard always only if Gui (not command line mode)
            self.updateURL = "http://arelle.org/downloads/8"
        elif sys.platform.startswith("win"):
            self.isMac = False
            self.isMSW = True
            if self.hasFileSystem and not configHomeDir:
                tempDir = tempfile.gettempdir()
                if tempDir.endswith('local\\temp'):
                    impliedAppDir = tempDir[:-10] + 'local'
                else:
                    impliedAppDir = tempDir
                self.userAppDir = os.path.join( impliedAppDir, "Arelle")
            if hasGui:
                try:
                    import win32clipboard
                    self.hasClipboard = True
                except ImportError:
                    self.hasClipboard = False
                try:
                    import win32gui
                    self.hasWin32gui = True # active state for open file dialogs
                except ImportError:
                    pass
            else:
                self.hasClipboard = False
            self.contextMenuClick = "<Button-3>"
            if "64 bit" in sys.version:
                self.updateURL = "http://arelle.org/downloads/9"
            else: # 32 bit
                self.updateURL = "http://arelle.org/downloads/10"
        else: # Unix/Linux
            self.isMac = False
            self.isMSW = False
            if self.hasFileSystem and not configHomeDir:
                    self.userAppDir = os.path.join( os.path.expanduser("~/.config"), "arelle")
            if hasGui:
                try:
                    import gtk
                    self.hasClipboard = True
                except ImportError:
                    self.hasClipboard = False
            else:
                self.hasClipboard = False
            self.contextMenuClick = "<Button-3>"
        try:
            from arelle import webserver
            self.hasWebServer = True
        except ImportError:
            self.hasWebServer = False
        # assert that app dir must exist
        self.config = None
        if self.hasFileSystem:
            if not os.path.exists(self.userAppDir):
                os.makedirs(self.userAppDir)
            # load config if it exists
            self.configJsonFile = self.userAppDir + os.sep + "config.json"
            if os.path.exists(self.configJsonFile):
                try:
                    with io.open(self.configJsonFile, 'rt', encoding='utf-8') as f:
                        self.config = json.load(f)
                except Exception as ex:
                    self.config = None # restart with a new config
        if not self.config:
            self.config = {
                'fileHistory': [],
                'windowGeometry': "{0}x{1}+{2}+{3}".format(800, 500, 200, 100),                
            }
            
        # start language translation for domain
        self.setUiLanguage(self.config.get("userInterfaceLangOverride",None), fallbackToDefault=True)
            
        from arelle.WebCache import WebCache
        self.webCache = WebCache(self, self.config.get("proxySettings"))
        self.modelManager = ModelManager.initialize(self)
        
        # start plug in server (requres web cache initialized, but not logger)
        PluginManager.init(self)
 
        # start taxonomy package server (requres web cache initialized, but not logger)
        PackageManager.init(self)
 
        self.startLogging(logFileName, logFileMode, logFileEncoding, logFormat)
        
        # Cntlr.Init after logging started
        for pluginMethod in PluginManager.pluginClassMethods("Cntlr.Init"):
            pluginMethod(self)
开发者ID:irjudson,项目名称:Arelle,代码行数:101,代码来源:Cntlr.py


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