• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python errors.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mozpack.errors.errors.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: handle_line

 def handle_line(self, str):
     f = str.strip()
     if not f:
         return
     if self.copier.contains(f):
         errors.error('Removal of packaged file(s): %s' % f)
     self.content += f + '\n'
开发者ID:npark-mozilla,项目名称:gecko-dev,代码行数:7,代码来源:packager.py


示例2: test_error_loop

 def test_error_loop(self):
     with self.assertRaises(AccumulatedErrors):
         with errors.accumulate():
             for i in range(3):
                 errors.error('%d' % i)
     self.assertEquals(self.get_output(),
                       ['Error: 0', 'Error: 1', 'Error: 2'])
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:7,代码来源:test_errors.py


示例3: _find

 def _find(self, path):
     '''
     UnifiedFinder.find() implementation.
     '''
     files1 = OrderedDict()
     for p, f in self._finder1.find(path):
         files1[p] = f
     files2 = set()
     for p, f in self._finder2.find(path):
         files2.add(p)
         if p in files1:
             if may_unify_binary(files1[p]) and \
                     may_unify_binary(f):
                 yield p, UnifiedExecutableFile(files1[p], f)
             else:
                 err = errors.count
                 unified = self.unify_file(p, files1[p], f)
                 if unified:
                     yield p, unified
                 elif err == errors.count:
                     self._report_difference(p, files1[p], f)
         else:
             errors.error('File missing in %s: %s' %
                          (self._finder1.base, p))
     for p in [p for p in files1 if not p in files2]:
         errors.error('File missing in %s: %s' % (self._finder2.base, p))
开发者ID:lazyparser,项目名称:gecko-dev,代码行数:26,代码来源:unify.py


示例4: add

 def add(self, section, pattern):
     '''
     Add files with the given pattern.
     '''
     assert not self._closed
     added = False
     for p, f in self._finder.find(pattern):
         added = True
         if is_manifest(p):
             self._manifests.add(p)
         self.packager.add(SimpleManifestSink.normalize_path(p), f)
     if not added:
         errors.error('Missing file(s): %s' % pattern)
开发者ID:RickEyre,项目名称:mozilla-central,代码行数:13,代码来源:__init__.py


示例5: add

 def add(self, path, content):
     """
     Add a BaseFile instance to the container, under the given path.
     """
     assert isinstance(content, BaseFile)
     if path in self._files:
         return errors.error("%s already added" % path)
     # Check whether any parent of the given path is already stored
     partial_path = path
     while partial_path:
         partial_path = mozpack.path.dirname(partial_path)
         if partial_path in self._files:
             return errors.error("Can't add %s: %s is a file" % (path, partial_path))
     self._files[path] = content
开发者ID:hibrium,项目名称:Pale-Moon,代码行数:14,代码来源:copier.py


示例6: add

 def add(self, component, pattern):
     '''
     Add files with the given pattern in the given component.
     '''
     assert not self._closed
     added = False
     for p, f in self._finder.find(pattern):
         added = True
         if is_manifest(p):
             self._manifests.add(p)
         dest = mozpath.join(component.destdir, SimpleManifestSink.normalize_path(p))
         self.packager.add(dest, f)
     if not added:
         errors.error('Missing file(s): %s' % pattern)
开发者ID:MekliCZ,项目名称:positron,代码行数:14,代码来源:__init__.py


示例7: _report_difference

 def _report_difference(self, path, file1, file2):
     '''
     Report differences between files in both trees.
     '''
     errors.error("Can't unify %s: file differs between %s and %s" %
                  (path, self._finder1.base, self._finder2.base))
     if not isinstance(file1, ExecutableFile) and \
             not isinstance(file2, ExecutableFile):
         from difflib import unified_diff
         for line in unified_diff(file1.open().readlines(),
                                  file2.open().readlines(),
                                  os.path.join(self._finder1.base, path),
                                  os.path.join(self._finder2.base, path)):
             errors.out.write(line)
开发者ID:lazyparser,项目名称:gecko-dev,代码行数:14,代码来源:unify.py


示例8: add

 def add(self, path, content):
     '''
     Add a BaseFile instance to the container, under the given path.
     '''
     assert isinstance(content, BaseFile)
     if path in self._files:
         return errors.error("%s already added" % path)
     if self._required_directories[path] > 0:
         return errors.error("Can't add %s: it is a required directory" %
                             path)
     # Check whether any parent of the given path is already stored
     partial_paths = self._partial_paths(path)
     for partial_path in partial_paths:
         if partial_path in self._files:
             return errors.error("Can't add %s: %s is a file" %
                                 (path, partial_path))
     self._files[path] = content
     self._required_directories.update(partial_paths)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:18,代码来源:copier.py


示例9: remove

 def remove(self, pattern):
     """
     Remove paths matching the given pattern from the container. See the
     mozpack.path.match documentation for a description of the handled
     patterns.
     """
     items = self.match(pattern)
     if not items:
         return errors.error("Can't remove %s: %s" % (pattern, "not matching anything previously added"))
     for i in items:
         del self._files[i]
开发者ID:hibrium,项目名称:Pale-Moon,代码行数:11,代码来源:copier.py


示例10: remove

 def remove(self, pattern):
     '''
     Remove paths matching the given pattern from the container. See the
     mozpack.path.match documentation for a description of the handled
     patterns.
     '''
     items = self.match(pattern)
     if not items:
         return errors.error("Can't remove %s: %s" % (pattern,
                             "not matching anything previously added"))
     for i in items:
         del self._files[i]
         self._required_directories.subtract(self._partial_paths(i))
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:13,代码来源:copier.py


示例11: test_multiple_errors

 def test_multiple_errors(self):
     with self.assertRaises(AccumulatedErrors):
         with errors.accumulate():
             errors.error('foo')
             for i in range(3):
                 if i == 2:
                     errors.warn('%d' % i)
                 else:
                     errors.error('%d' % i)
             errors.error('bar')
     self.assertEquals(self.get_output(),
                       ['Error: foo', 'Error: 0', 'Error: 1',
                        'Warning: 2', 'Error: bar'])
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:13,代码来源:test_errors.py


示例12: test_errors_context

 def test_errors_context(self):
     with self.assertRaises(AccumulatedErrors):
         with errors.accumulate():
             self.assertEqual(errors.get_context(), None)
             with errors.context('foo', 1):
                 self.assertEqual(errors.get_context(), ('foo', 1))
                 errors.error('a')
                 with errors.context('bar', 2):
                     self.assertEqual(errors.get_context(), ('bar', 2))
                     errors.error('b')
                 self.assertEqual(errors.get_context(), ('foo', 1))
                 errors.error('c')
     self.assertEqual(self.get_output(), [
         'Error: foo:1: a',
         'Error: bar:2: b',
         'Error: foo:1: c',
     ])
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:17,代码来源:test_errors.py


示例13: _repack

def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
    app = LocaleManifestFinder(app_finder)
    l10n = LocaleManifestFinder(l10n_finder)

    # The code further below assumes there's only one locale replaced with
    # another one.
    if len(app.locales) > 1 or len(l10n.locales) > 1:
        errors.fatal("Multiple locales aren't supported")
    locale = app.locales[0]
    l10n_locale = l10n.locales[0]

    # For each base directory, store what path a locale chrome package name
    # corresponds to.
    # e.g., for the following entry under app/chrome:
    #     locale foo en-US path/to/files
    # keep track that the locale path for foo in app is
    # app/chrome/path/to/files.
    l10n_paths = {}
    for e in l10n.entries:
        if isinstance(e, ManifestChrome):
            base = mozpath.basedir(e.path, app.bases)
            l10n_paths.setdefault(base, {})
            l10n_paths[base][e.name] = e.path

    # For chrome and non chrome files or directories, store what langpack path
    # corresponds to a package path.
    paths = {}
    for e in app.entries:
        if isinstance(e, ManifestEntryWithRelPath):
            base = mozpath.basedir(e.path, app.bases)
            if base not in l10n_paths:
                errors.fatal("Locale doesn't contain %s/" % base)
                # Allow errors to accumulate
                continue
            if e.name not in l10n_paths[base]:
                errors.fatal("Locale doesn't have a manifest entry for '%s'" %
                    e.name)
                # Allow errors to accumulate
                continue
            paths[e.path] = l10n_paths[base][e.name]

    for pattern in non_chrome:
        for base in app.bases:
            path = mozpath.join(base, pattern)
            left = set(p for p, f in app_finder.find(path))
            right = set(p for p, f in l10n_finder.find(path))
            for p in right:
                paths[p] = p
            for p in left - right:
                paths[p] = None

    # Create a new package, with non localized bits coming from the original
    # package, and localized bits coming from the langpack.
    packager = SimplePackager(formatter)
    for p, f in app_finder:
        if is_manifest(p):
            # Remove localized manifest entries.
            for e in [e for e in f if e.localized]:
                f.remove(e)
        # If the path is one that needs a locale replacement, use the
        # corresponding file from the langpack.
        path = None
        if p in paths:
            path = paths[p]
            if not path:
                continue
        else:
            base = mozpath.basedir(p, paths.keys())
            if base:
                subpath = mozpath.relpath(p, base)
                path = mozpath.normpath(mozpath.join(paths[base],
                                                               subpath))
        if path:
            files = [f for p, f in l10n_finder.find(path)]
            if not len(files):
                if base not in non_chrome:
                    errors.error("Missing file: %s" %
                                 os.path.join(l10n_finder.base, path))
            else:
                packager.add(path, files[0])
        else:
            packager.add(p, f)

    # Add localized manifest entries from the langpack.
    l10n_manifests = []
    for base in set(e.base for e in l10n.entries):
        m = ManifestFile(base, [e for e in l10n.entries if e.base == base])
        path = mozpath.join(base, 'chrome.%s.manifest' % l10n_locale)
        l10n_manifests.append((path, m))
    bases = packager.get_bases()
    for path, m in l10n_manifests:
        base = mozpath.basedir(path, bases)
        packager.add(path, m)
        # Add a "manifest $path" entry in the top manifest under that base.
        m = ManifestFile(base)
        m.add(Manifest(base, mozpath.relpath(path, base)))
        packager.add(mozpath.join(base, 'chrome.manifest'), m)

    packager.close()

#.........这里部分代码省略.........
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:101,代码来源:l10n.py


示例14: test_simple_error

 def test_simple_error(self):
     with self.assertRaises(AccumulatedErrors):
         with errors.accumulate():
             errors.error('1')
     self.assertEquals(self.get_output(), ['Error: 1'])
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:5,代码来源:test_errors.py


示例15: test_ignore_errors

 def test_ignore_errors(self):
     errors.ignore_errors()
     errors.warn('foo')
     errors.error('bar')
     self.assertRaises(ErrorMessage, errors.fatal, 'foo')
     self.assertEquals(self.get_output(), ['Warning: foo', 'Warning: bar'])
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:6,代码来源:test_errors.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python errors.fatal函数代码示例发布时间:2022-05-27
下一篇:
Python copier.FileRegistry类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap