当前位置: 首页>>代码示例>>Python>>正文


Python XPIManager.package_contents方法代码示例

本文整理汇总了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')
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:10,代码来源:test_xpimanager.py

示例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")
开发者ID:clouserw,项目名称:amo-validator,代码行数:11,代码来源:test_xpimanager.py

示例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
开发者ID:kewisch,项目名称:amo-validator,代码行数:25,代码来源:test_typedetection.py

示例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
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:7,代码来源:test_xpimanager.py

示例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
开发者ID:robhudson,项目名称:amo-validator,代码行数:8,代码来源:test_xpimanager.py

示例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)
开发者ID:rmoorman,项目名称:transifex-adofex,代码行数:63,代码来源:bundle.py

示例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
开发者ID:krupa,项目名称:amo-validator,代码行数:8,代码来源:test_xpimanager.py

示例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()
开发者ID:krupa,项目名称:amo-validator,代码行数:6,代码来源:test_xpimanager.py


注:本文中的validator.xpi.XPIManager.package_contents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。