本文整理汇总了Python中validator.xpi.XPIManager.app_name方法的典型用法代码示例。如果您正苦于以下问题:Python XPIManager.app_name方法的具体用法?Python XPIManager.app_name怎么用?Python XPIManager.app_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.xpi.XPIManager
的用法示例。
在下文中一共展示了XPIManager.app_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lp_xpi
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import app_name [as 别名]
def test_lp_xpi(err, xpi_package):
'Tests a language pack for L10n completeness'
# Don't even both with the test(s) if there's no chrome.manifest.
if 'chrome.manifest' not in xpi_package:
return None
locales = _get_locales(err)
# Get the reference packages.
references = []
support_references = err.get_resource('supports')
if not support_references:
references.append('firefox')
err.info(('testcases_l10ncompleteness',
'test_lp_xpi',
'missing_app_support'),
'Supported app missing in localization completeness.',
'While testing in localization comleteness, a list of '
'supported applications for the language pack was not found. '
'This is likely because there are no listed '
'<em:targetApplication> elements in the install.rdf file.')
else:
for support in support_references:
ref_xpi = XPIManager(os.path.join(os.path.dirname(__file__),
'langpacks/%s.xpi' % support))
ref_xpi.app_name = support
reference_locales = _get_locales(None, ref_xpi)
references.append((ref_xpi, reference_locales))
# Iterate each supported reference package
for (ref_xpi, ref_locales) in references:
# Iterate each locale in each supported reference package
ref_pack = _get_locale_manager(err,
ref_xpi,
{'path': 'en-US.jar',
'jarred': True},
no_cache=True)
for ref_locale_name in ref_locales:
ref_locale = ref_locales[ref_locale_name]
ref_predicate = ref_locale['predicate']
corresp_locales = [locales[name] for name
in locales
if locales[name]['predicate'] == ref_predicate]
# If we found no matching locale, then it's missing from the pack
if not corresp_locales:
err.warning(('testcases_l10ncompleteness',
'test_lp_xpi',
'find_corresponding_locale'),
'Could not find corresponding locale',
['A locale was found in the reference package, '
'however it was not found in the target package.',
'Missing locale: %s' % ref_predicate],
filename='chrome.manifest')
continue
target_locale = corresp_locales[0]
target_pack = _get_locale_manager(err,
xpi_package,
target_locale)
if target_pack is None:
continue
results = _compare_packages(reference=ref_pack,
target=target_pack,
ref_base=ref_locale['target'],
locale_base=target_locale['target'])
# Report the findings after each supported app's locale
_aggregate_results(err, results, target_locale)
# Clear the cache at the end of the test
LOCALE_CACHE.clear()
示例2: test_lp_xpi
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import app_name [as 别名]
def test_lp_xpi(err, xpi_package):
"Tests a language pack for L10n completeness"
# Don't even both with the test(s) if there's no chrome.manifest.
if "chrome.manifest" not in xpi_package:
return None
locales = _get_locales(err)
# Get the reference packages.
references = []
support_references = err.get_resource("supports")
if not support_references:
references.append("firefox")
err.info(
("testcases_l10ncompleteness", "test_lp_xpi", "missing_app_support"),
"Supported app missing in localization completeness.",
"While testing in localization comleteness, a list of "
"supported applications for the language pack was not found. "
"This is likely because there are no listed "
"<em:targetApplication> elements in the install.rdf file.",
)
else:
for support in support_references:
ref_xpi = XPIManager(os.path.join(os.path.dirname(__file__), "langpacks/%s.xpi" % support))
ref_xpi.app_name = support
reference_locales = _get_locales(None, ref_xpi)
references.append((ref_xpi, reference_locales))
# Iterate each supported reference package
for (ref_xpi, ref_locales) in references:
# Iterate each locale in each supported reference package
ref_pack = _get_locale_manager(err, ref_xpi, {"path": "en-US.jar", "jarred": True}, no_cache=True)
for ref_locale_name in ref_locales:
ref_locale = ref_locales[ref_locale_name]
ref_predicate = ref_locale["predicate"]
corresp_locales = [locales[name] for name in locales if locales[name]["predicate"] == ref_predicate]
# If we found no matching locale, then it's missing from the pack
if not corresp_locales:
err.warning(
("testcases_l10ncompleteness", "test_lp_xpi", "find_corresponding_locale"),
"Could not find corresponding locale",
[
"A locale was found in the reference package, "
"however it was not found in the target package.",
"Missing locale: %s" % ref_predicate,
],
filename="chrome.manifest",
)
continue
target_locale = corresp_locales[0]
target_pack = _get_locale_manager(err, xpi_package, target_locale)
if target_pack is None:
continue
results = _compare_packages(
reference=ref_pack,
target=target_pack,
ref_base=ref_locale["target"],
locale_base=target_locale["target"],
)
# Report the findings after each supported app's locale
_aggregate_results(err, results, target_locale)
# Clear the cache at the end of the test
LOCALE_CACHE = {}