本文整理汇总了Python中arelle.PackageManager.init方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.init方法的具体用法?Python PackageManager.init怎么用?Python PackageManager.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.PackageManager
的用法示例。
在下文中一共展示了PackageManager.init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import init [as 别名]
def __init__(self, hasGui=False, logFileName=None, logFileMode=None, logFileEncoding=None, logFormat=None):
self.hasWin32gui = False
self.hasGui = hasGui
self.hasFileSystem = True # no file system on Google App Engine servers
self.isGAE = False
self.systemWordSize = int(round(math.log(sys.maxsize, 2)) + 1) # e.g., 32 or 64
self.moduleDir = os.path.dirname(__file__)
# for python 3.2 remove __pycache__
if self.moduleDir.endswith("__pycache__"):
self.moduleDir = os.path.dirname(self.moduleDir)
if self.moduleDir.endswith("python32.zip/arelle"):
'''
distZipFile = os.path.dirname(self.moduleDir)
d = os.path.join(self.userAppDir, "arelle")
self.configDir = os.path.join(d, "config")
self.imagesDir = os.path.join(d, "images")
import zipfile
distZip = zipfile.ZipFile(distZipFile, mode="r")
distNames = distZip.namelist()
distZip.extractall(path=self.userAppDir,
members=[f for f in distNames if "/config/" in f or "/images/" in f]
)
distZip.close()
'''
resources = os.path.dirname(os.path.dirname(os.path.dirname(self.moduleDir)))
self.configDir = os.path.join(resources, "config")
self.imagesDir = os.path.join(resources, "images")
self.localeDir = os.path.join(resources, "locale")
self.pluginDir = os.path.join(resources, "plugin")
elif self.moduleDir.endswith("library.zip\\arelle") or self.moduleDir.endswith("library.zip/arelle"): # cx_Freexe
resources = os.path.dirname(os.path.dirname(self.moduleDir))
self.configDir = os.path.join(resources, "config")
self.imagesDir = os.path.join(resources, "images")
self.localeDir = os.path.join(resources, "locale")
self.pluginDir = os.path.join(resources, "plugin")
else:
self.configDir = os.path.join(self.moduleDir, "config")
self.imagesDir = os.path.join(self.moduleDir, "images")
self.localeDir = os.path.join(self.moduleDir, "locale")
self.pluginDir = os.path.join(self.moduleDir, "plugin")
serverSoftware = os.getenv("SERVER_SOFTWARE", "")
if serverSoftware.startswith("Google App Engine/") or serverSoftware.startswith("Development/"):
self.hasFileSystem = False # no file system, userAppDir does not exist
self.isGAE = True
configHomeDir = None # look for path configDir/CONFIG_HOME in argv and environment parameters
for i, arg in enumerate(sys.argv): # check if config specified in a argv
if arg.startswith("--xdgConfigHome="):
configHomeDir = arg[16:]
break
elif arg == "--xdgConfigHome" and i + 1 < len(sys.argv):
configHomeDir = sys.argv[i + 1]
break
if not configHomeDir: # not in argv, may be an environment parameter
configHomeDir = os.getenv('XDG_CONFIG_HOME')
if not configHomeDir: # look for path configDir/CONFIG_HOME
configHomeDirFile = os.path.join(self.configDir, "XDG_CONFIG_HOME")
if os.path.exists(configHomeDirFile):
try:
with io.open(configHomeDirFile, 'rt', encoding='utf-8') as f:
configHomeDir = f.read().strip()
if configHomeDir and not os.path.isabs(configHomeDir):
configHomeDir = os.path.abspath(configHomeDir) # make into a full path if relative
except EnvironmentError:
configHomeDir = None
if self.hasFileSystem and configHomeDir and os.path.exists(configHomeDir):
# check if a cache exists in this directory (e.g. from XPE or other tool)
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:
#.........这里部分代码省略.........