本文整理汇总了Python中arelle.PackageManager.addPackage方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.addPackage方法的具体用法?Python PackageManager.addPackage怎么用?Python PackageManager.addPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.PackageManager
的用法示例。
在下文中一共展示了PackageManager.addPackage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open_package_file
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import addPackage [as 别名]
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
示例2: get_packages_info
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import addPackage [as 别名]
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
示例3: run
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import addPackage [as 别名]
#.........这里部分代码省略.........
else: # assume it is a module or package
savePluginChanges = False
moduleInfo = PluginManager.addPluginModule(cmd)
if moduleInfo:
self.addToLog(_("Activation of plug-in {0} successful.").format(moduleInfo.get("name")),
messageCode="info", file=moduleInfo.get("moduleURL"))
resetPlugins = True
else:
self.addToLog(_("Unable to load {0} as a plug-in or {0} is not recognized as a command. ").format(cmd), messageCode="info", file=cmd)
if resetPlugins:
PluginManager.reset()
if savePluginChanges:
PluginManager.save(self)
if showPluginModules:
self.addToLog(_("Plug-in modules:"), messageCode="info")
for i, moduleItem in enumerate(sorted(PluginManager.pluginConfig.get("modules", {}).items())):
moduleInfo = moduleItem[1]
self.addToLog(_("Plug-in: {0}; author: {1}; version: {2}; status: {3}; date: {4}; description: {5}; license {6}.").format(
moduleItem[0], moduleInfo.get("author"), moduleInfo.get("version"), moduleInfo.get("status"),
moduleInfo.get("fileDate"), moduleInfo.get("description"), moduleInfo.get("license")),
messageCode="info", file=moduleInfo.get("moduleURL"))
if options.packages:
from arelle import PackageManager
savePackagesChanges = True
showPackages = False
for packageCmd in options.packages.split('|'):
cmd = packageCmd.strip()
if cmd == "show":
showPackages = True
elif cmd == "temp":
savePackagesChanges = False
elif cmd.startswith("+"):
packageInfo = PackageManager.addPackage(cmd[1:])
if packageInfo:
self.addToLog(_("Addition of package {0} successful.").format(packageInfo.get("name")),
messageCode="info", file=packageInfo.get("URL"))
else:
self.addToLog(_("Unable to load plug-in."), messageCode="info", file=cmd[1:])
elif cmd.startswith("~"):
if PackageManager.reloadPackageModule(cmd[1:]):
self.addToLog(_("Reload of package successful."), messageCode="info", file=cmd[1:])
else:
self.addToLog(_("Unable to reload package."), messageCode="info", file=cmd[1:])
elif cmd.startswith("-"):
if PackageManager.removePackageModule(cmd[1:]):
self.addToLog(_("Deletion of package successful."), messageCode="info", file=cmd[1:])
else:
self.addToLog(_("Unable to delete package."), messageCode="info", file=cmd[1:])
else: # assume it is a module or package
savePackagesChanges = False
packageInfo = PackageManager.addPackage(cmd)
if packageInfo:
self.addToLog(_("Activation of package {0} successful.").format(packageInfo.get("name")),
messageCode="info", file=packageInfo.get("URL"))
resetPlugins = True
else:
self.addToLog(_("Unable to load {0} as a package or {0} is not recognized as a command. ").format(cmd), messageCode="info", file=cmd)
if savePackagesChanges:
PackageManager.save(self)
if showPackages:
self.addToLog(_("Taxonomy packages:"), messageCode="info")
for packageInfo in PackageManager.orderedPackagesConfig()["packages"]:
self.addToLog(_("Package: {0}; version: {1}; status: {2}; date: {3}; description: {4}.").format(
packageInfo.get("name"), packageInfo.get("version"), packageInfo.get("status"),
packageInfo.get("fileDate"), packageInfo.get("description")),