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


Python XPIManager.write方法代码示例

本文整理汇总了Python中validator.xpi.XPIManager.write方法的典型用法代码示例。如果您正苦于以下问题:Python XPIManager.write方法的具体用法?Python XPIManager.write怎么用?Python XPIManager.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator.xpi.XPIManager的用法示例。


在下文中一共展示了XPIManager.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_write_file

# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import write [as 别名]
def test_write_file():
    """Test that a file can be written in UTF-8 to the package."""
    with tempfile.NamedTemporaryFile(delete=False) as t:
        temp_fn = t.name
        try:
            z = XPIManager(temp_fn, mode='w')
            f, d = 'install.rdf', '注目のコレクション'.decode('utf-8')
            z.write(f, d)
            eq_(z.read(f), d.encode('utf-8'))
        finally:
            os.unlink(temp_fn)
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:13,代码来源:test_xpimanager.py

示例2: packager

# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import write [as 别名]
def packager(data, xpi_path, features):
    """Package an add-on from input data. The resulting package will be
    saved as xpi_path.

    data format:
        - id : <em:id> value
        - version : <em:version>
        - name : <em:name>
        - description : <em:description>
        - author_name : <em:author>
        - contributors : \n-delimited list of contributors
        - targetapplications : Dict in the form of:
            {
                "min_ver": "3.6",
                "max_ver": "6.0a1",
                "guid": "...",
            }
        - uuid : A UUID value that is unique to this package
        - slug : A slug value based on the name which will be used as a
                 package identifier.

    xpi_path should be the file path to build the XPI at.

    features should be a set containing string names of each of the
    features to include.

    """

    # Sanitize the slug.
    data['slug'] = _slugify(data.get('slug', ''))

    # Instantiate the XPI Manager.
    from validator.xpi import XPIManager
    xpi = XPIManager(xpi_path, mode='w')

    xpi.write('install.rdf', build_installrdf(data, features))
    xpi.write('chrome.manifest', build_chrome_manifest(data, features))

    # Sanitize all the input after building `install.rdf` (which is escaped
    # when jinja renders the template) to prevent doubly escaping the input.
    data = escape_all(data)

    _write_resource('defaults/preferences/prefs.js', xpi, data)
    _write_resource('chrome/skin/overlay.css', xpi, data)
    _write_resource('chrome/locale/en-US/overlay.dtd', xpi, data)
    _write_resource('chrome/locale/en-US/overlay.properties', xpi, data)

    if 'about_dialog' in features:
        _write_resource('chrome/content/about.xul', xpi, data)
        _write_resource('chrome/locale/en-US/about.dtd', xpi)

    if 'preferences_dialog' in features:
        _write_resource('chrome/content/options.xul', xpi, data)
        _write_resource('chrome/locale/en-US/options.dtd', xpi, data)

    if 'toolbar_button' in features:
        _write_resource('chrome/skin/toolbar-button.png', xpi)

    if 'sidebar_support' in features:
        _write_resource('chrome/content/ff-sidebar.js', xpi)
        _write_resource('chrome/content/ff-sidebar.xul', xpi, data)

    xpi.write('chrome/content/ff-overlay.xul',
              build_ffoverlay_xul(data, features))
    _write_resource('chrome/content/ff-overlay.js', xpi, data)

    xpi.zf.close()
    return xpi_path
开发者ID:cvan,项目名称:addon-packager,代码行数:70,代码来源:main.py


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