本文整理汇总了Python中validator.xpi.XPIManager.package_contents方法的典型用法代码示例。如果您正苦于以下问题:Python XPIManager.package_contents方法的具体用法?Python XPIManager.package_contents怎么用?Python XPIManager.package_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.xpi.XPIManager
的用法示例。
在下文中一共展示了XPIManager.package_contents方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_list
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_get_list():
"""Test that the manager can read the file listing."""
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
assert not z.contents_cache
assert z.package_contents()
assert z.contents_cache # Spelling check!
z.contents_cache = 'foo'
eq_(z.package_contents(), 'foo')
示例2: test_get_list
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_get_list():
"Test that the manager can read the file listing"
z = XPIManager("tests/resources/xpi/install_rdf_only.xpi")
assert not z.contents_cache
assert z.package_contents()
assert z.contents_cache # Spelling check!
z.contents_cache = "foo"
eq_(z.package_contents(), "foo")
示例3: _test_type
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def _test_type(file_, expectation, failure=False):
'Tests a file against the expectations'
err = ErrorBundle(None, True)
package = XPIManager(open(file_), mode='r', name=file_)
contents = package.package_contents()
# We need to have an install.rdf.
assert 'install.rdf' in contents
# Load up the install.rdf into an RDFParser
install_file = package.read('install.rdf')
install_rdf = RDFParser(err, install_file)
results = typedetection.detect_type(err, install_rdf, package)
assert results == expectation
if not failure:
assert not err.failed()
else:
assert err.failed()
return err
示例4: test_valid_name
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_valid_name():
"Test that the manager can retrieve the correct file name."
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
contents = z.package_contents()
assert 'install.rdf' in contents
示例5: test_valid_name
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_valid_name():
"Test that the manager can retrieve the correct file name."
z = XPIManager(get_path("xpi/install_rdf_only.xpi"))
contents = z.package_contents()
assert "install.rdf" in contents
assert z.test() == False
示例6: __init__
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def __init__(self, filename, project=None, release=None, name=None):
"""
Fills in a list of locales from the chrome.manifest file.
"""
Bundle.__init__(self, project, release)
self.xpi = XPIManager(filename, name=name)
# here we will store managers for jarfiles
self.jarfiles = {}
chrome = ChromeManifest(self.xpi.read("chrome.manifest"), "manifest")
locales = list(chrome.get_triples("locale"))
if not locales:
return None
# read the list
for locale in locales:
code, location = locale["object"].split()
# finding out the language of the locale
try:
lang = self._get_lang(code)
except Language.DoesNotExist:
self.log("Locale %s SKIPPED" % code, "font-weight:bold")
continue
# Locales can be bundled in JARs
jarred = location.startswith("jar:")
if jarred:
# We just care about the JAR path
location = location[4:]
split_location = location.split("!", 2)
# Ignore malformed JAR URIs.
if len(split_location) < 2:
continue
jarname, location = split_location
# missing file mentioned
if jarname not in self.xpi:
continue
# may be we have already read this one
if jarname in self.jarfiles:
package = self.jarfiles[jarname]
else:
jar = StringIO(self.xpi.read(jarname))
package = XPIManager(jar, mode="r", name=jarname)
else:
package = self.xpi
# and now we read files from there
location = location.strip('/')
result = {}
for f in package.package_contents():
f = f.strip("/")
if f.startswith(location) and f != location:
result[f.split("/")[-1]] = package.read(f)
# file with same name in different jars can get overwritten
if lang not in self.locales:
self.locales[lang] = result
else:
self.locales[lang].update(result)
示例7: test_valid_name
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_valid_name():
"Test that the manager can retrieve the correct file name"
z = XPIManager("tests/resources/xpi/install_rdf_only.xpi")
contents = z.package_contents()
assert "install.rdf" in contents
assert z.test() == False
示例8: test_get_list
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import package_contents [as 别名]
def test_get_list():
"Test that the manager can read the file listing"
z = XPIManager("tests/resources/xpi/install_rdf_only.xpi")
assert z.package_contents()