本文整理汇总了Python中arelle.PackageManager.parsePackage方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.parsePackage方法的具体用法?Python PackageManager.parsePackage怎么用?Python PackageManager.parsePackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.PackageManager
的用法示例。
在下文中一共展示了PackageManager.parsePackage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import parsePackage [as 别名]
return # provide error message later
except etree.LxmlError, 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(_(u"Taxonomy package must contain one and only one metadata file: {0}.")
.format(u', '.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(u"/", os.sep)))
for prefix, remapping in taxonomyPackage[u"remappings"].items())
except EnvironmentError, err:
self.logError(err)
return # provide error message later
def openZipStream(self, sourceZipStream):
if not self.isOpen:
self.basefile = self.url
self.baseurl = self.url # url gets changed by selection
self.fs = zipfile.ZipFile(sourceZipStream, mode=u"r")
示例2: open
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import parsePackage [as 别名]
#.........这里部分代码省略.........
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
示例3: loadTaxonomyPackageMappings
# 需要导入模块: from arelle import PackageManager [as 别名]
# 或者: from arelle.PackageManager import parsePackage [as 别名]
def loadTaxonomyPackageMappings(self):
if self.taxonomyPackageMetadataFiles:
metadata = self.url + os.sep + self.taxonomyPackageMetadataFiles[0]
taxonomyPackage = PackageManager.parsePackage(self.cntlr, self, metadata,
os.sep.join(os.path.split(metadata)[:-1]) + os.sep)
self.mappedPaths = taxonomyPackage["remappings"]