本文整理汇总了Python中arelle.PluginManager类的典型用法代码示例。如果您正苦于以下问题:Python PluginManager类的具体用法?Python PluginManager怎么用?Python PluginManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ok
def ok(self, event=None):
if self.pluginConfigChanged:
PluginManager.pluginConfig = self.pluginConfig
PluginManager.pluginConfigChanged = True
PluginManager.reset() # force reloading of modules
if self.uiClassMethodsChanged or self.modelClassesChanged or self.disclosureSystemTypesChanged or self.hostSystemFeaturesChanged: # may require reloading UI
affectedItems = ""
if self.uiClassMethodsChanged:
affectedItems += _("menus of the user interface")
if self.modelClassesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("model objects of the processor")
if self.disclosureSystemTypesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("disclosure system types")
if self.hostSystemFeaturesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("host system features")
if messagebox.askyesno(_("User interface plug-in change"),
_("A change in plug-in class methods may have affected {0}. "
"Please restart Arelle to due to these changes. \n\n"
"Should Arelle restart itself now "
"(if there are any unsaved changes they would be lost!)?"
).format(affectedItems),
parent=self):
self.cntlr.uiThreadQueue.put((self.cntlr.quit, [None, True]))
self.close()
示例2: close
def close(self, saveConfig=False):
""".. method:: close(saveConfig=False)
Close controller and its logger, optionally saaving the user preferences configuration
:param saveConfig: save the user preferences configuration"""
PluginManager.save(self)
if saveConfig:
self.saveConfig()
if self.logger is not None:
self.logHandler.close()
示例3: ok
def ok(self, event=None):
if self.pluginConfigChanged:
PluginManager.pluginConfig = self.pluginConfig
PluginManager.pluginConfigChanged = True
PluginManager.reset() # force reloading of modules
if self.uiClassMethodsChanged: # may require reloading UI
messagebox.showwarning(_("User interface plug-in change"),
_("A change in plug-in class methods may have affected the menus "
"of the user interface. It may be necessary to restart Arelle to "
"access the menu entries or the changes to their plug-in methods."),
parent=self)
self.close()
示例4: 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)
if saveConfig:
self.saveConfig()
if self.logger is not None:
try:
self.logHandler.close()
except Exception: # fails on some earlier pythons (3.1)
pass
示例5: ok
def ok(self, event=None):
if self.pluginConfigChanged:
PluginManager.pluginConfig = self.pluginConfig
PluginManager.pluginConfigChanged = True
PluginManager.reset() # force reloading of modules
if self.uiClassMethodsChanged: # may require reloading UI
if messagebox.askyesno(_("User interface plug-in change"),
_("A change in plug-in class methods may have affected the menus "
"of the user interface. It may be necessary to restart Arelle to "
"access the menu entries or the changes to their plug-in methods. \n\n"
"Should Arelle restart with changed user interface language, "
"(if there are any unsaved changes they would be lost!)?"),
parent=self):
self.cntlr.uiThreadQueue.put((self.cntlr.quit, [None, True]))
self.close()
示例6: ok
def ok(self, event=None):
# check for orphaned classes (for which there is no longer a corresponding module)
_moduleNames = self.pluginConfig.get("modules", {}).keys()
_orphanedClassNames = set()
for className, moduleList in self.pluginConfig.get("classes", {}).items():
for _moduleName in moduleList.copy():
if _moduleName not in _moduleNames: # it's orphaned
moduleList.remove(_moduleName)
self.pluginConfigChanged = True
if not moduleList: # now orphaned
_orphanedClassNames.add(className)
self.pluginConfigChanged = True
for _orphanedClassName in _orphanedClassNames:
del self.pluginConfig["classes"][_orphanedClassName]
if self.pluginConfigChanged:
PluginManager.pluginConfig = self.pluginConfig
PluginManager.pluginConfigChanged = True
PluginManager.reset() # force reloading of modules
if self.uiClassMethodsChanged or self.modelClassesChanged or self.customTransformsChanged or self.disclosureSystemTypesChanged or self.hostSystemFeaturesChanged: # may require reloading UI
affectedItems = ""
if self.uiClassMethodsChanged:
affectedItems += _("menus of the user interface")
if self.modelClassesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("model objects of the processor")
if self.customTransformsChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("custom transforms")
if self.disclosureSystemTypesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("disclosure system types")
if self.hostSystemFeaturesChanged:
if affectedItems:
affectedItems += _(" and ")
affectedItems += _("host system features")
if messagebox.askyesno(_("User interface plug-in change"),
_("A change in plug-in class methods may have affected {0}. "
"Please restart Arelle to due to these changes. \n\n"
"Should Arelle restart itself now "
"(if there are any unsaved changes they would be lost!)?"
).format(affectedItems),
parent=self):
self.cntlr.uiThreadQueue.put((self.cntlr.quit, [None, True]))
self.close()
示例7: selectLocally
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)
示例8: moduleReload
def moduleReload(self):
if self.selectedModule in self.pluginConfig["modules"]:
url = self.pluginConfig["modules"][self.selectedModule].get("moduleURL")
if url:
moduleInfo = PluginManager.moduleModuleInfo(url, reload=True)
if moduleInfo:
self.addPluginConfigModuleInfo(moduleInfo)
self.loadTreeViews()
self.cntlr.showStatus(_("{0} reloaded").format(moduleInfo.get("name")), clearAfter=5000)
示例9: backgroundCheckForUpdates
def backgroundCheckForUpdates(cntlr):
cntlr.showStatus(_("Checking for updates to plug-ins")) # clear web loading status
modulesWithNewerFileDates = PluginManager.modulesWithNewerFileDates()
if modulesWithNewerFileDates:
cntlr.showStatus(_("Updates are available for these plug-ins: {0}")
.format(', '.join(modulesWithNewerFileDates)), clearAfter=5000)
else:
cntlr.showStatus(_("No updates found for plug-ins."), clearAfter=5000)
time.sleep(0.1) # Mac locks up without this, may be needed for empty ui queue?
cntlr.uiThreadQueue.put((DialogPluginManager, [cntlr, modulesWithNewerFileDates]))
示例10: findLocally
def findLocally(self):
filename = self.cntlr.uiFileDialog("open",
owner=self,
title=_("Choose plug-in module file"),
initialdir=self.cntlr.config.setdefault("pluginOpenDir","."),
filetypes=[(_("Python files"), "*.py")],
defaultextension=".py")
if filename:
self.cntlr.config["pluginOpenDir"] = os.path.dirname(filename)
moduleInfo = PluginManager.moduleModuleInfo(filename)
self.loadFoundModuleInfo(moduleInfo, filename)
示例11: moduleReload
def moduleReload(self):
if self.selectedModule in self.pluginConfig["modules"]:
url = self.pluginConfig["modules"][self.selectedModule].get("moduleURL")
if url:
moduleInfo = PluginManager.moduleModuleInfo(url, reload=True)
if moduleInfo:
self.addPluginConfigModuleInfo(moduleInfo)
self.loadTreeViews()
self.cntlr.showStatus(_("{0} reloaded").format(moduleInfo.get("name")), clearAfter=5000)
else:
messagebox.showwarning(_("Module error"),
_("File or module cannot be reloaded: \n\n{0}")
.format(url),
parent=self)
示例12: 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("pluginOpenDir", initialdir)
filename = self.cntlr.uiFileDialog("open",
parent=self,
title=_("Choose plug-in module file"),
initialdir=initialdir,
filetypes=[(_("Python files"), "*.py")],
defaultextension=".py")
if filename:
# check if a package is selected (any file in a directory containing an __init__.py
#if (os.path.basename(filename) == "__init__.py" and os.path.isdir(os.path.dirname(filename)) and
# os.path.isfile(filename)):
# filename = os.path.dirname(filename) # refer to the package instead
self.cntlr.config["pluginOpenDir"] = os.path.dirname(filename)
moduleInfo = PluginManager.moduleModuleInfo(filename)
self.loadFoundModuleInfo(moduleInfo, filename)
示例13: selectChoices
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
示例14: findOnWeb
def findOnWeb(self):
url = DialogURL.askURL(self)
if url: # url is the in-cache or local file
moduleInfo = PluginManager.moduleModuleInfo(url)
self.cntlr.showStatus("") # clear web loading status
self.loadFoundModuleInfo(moduleInfo, url)
示例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)