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

Python console.red函数代码示例

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

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



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

示例1: init

 def init(self):
     I18nBuilder.init(self)
     errors = False
     if not self.config.omegat_project_path:
         self.info(red("'omegat_project_path' should not be empty."))
         self.info(red("    -> Please check conf.py"))
         raise RuntimeError("lack setting")
开发者ID:Lemma1,项目名称:MINAMI,代码行数:7,代码来源:builder.py


示例2: verify_everything_documented

def verify_everything_documented(app, exception):  # pragma: no cover
    if exception:
        return

    bad = False
    app.info(console.white("checking that all REST API types are included in the documentation"))
    documented_types = app.env.domaindata['api']['types']
    for ty in wsme.types.Base.__subclasses__():
        if not ty.__module__.startswith('relengapi.') or '.test_' in ty.__module__:
            continue
        tyname = typename(ty)
        if tyname not in documented_types:
            app.warn(console.red("Type '%s' is not documented" % (tyname,)))
            bad = True

    app.info(console.white("checking that all API endpoints are included in the documentation"))
    all_endpoints = set(ep for ep, func in current_app.view_functions.items()
                        if hasattr(func, '__apidoc__'))
    documented_endpoints = app.env.domaindata['api']['endpoints']
    for undoc in all_endpoints - documented_endpoints:
        app.warn(console.red("Endpoint '%s' is not documented" % (undoc,)))
        bad = True

    if bad:
        raise RuntimeError("missing API documentation")
开发者ID:amyrrich,项目名称:build-relengapi,代码行数:25,代码来源:apidoc.py


示例3: do_prompt

def do_prompt(d, key, text, default=None, validator=nonempty):
    while True:
        if default:
            prompt = purple(PROMPT_PREFIX + '%s [%s]: ' % (text, default))
        else:
            prompt = purple(PROMPT_PREFIX + text + ': ')
        x = term_input(prompt)
        if default and not x:
            x = default
        if not isinstance(x, unicode):
            # for Python 2.x, try to get a Unicode string out of it
            if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
                if TERM_ENCODING:
                    x = x.decode(TERM_ENCODING)
                else:
                    print turquoise('* Note: non-ASCII characters entered '
                                    'and terminal encoding unknown -- assuming '
                                    'UTF-8 or Latin-1.')
                    try:
                        x = x.decode('utf-8')
                    except UnicodeDecodeError:
                        x = x.decode('latin1')
        try:
            x = validator(x)
        except ValidationError, err:
            print red('* ' + str(err))
            continue
        break
开发者ID:certik,项目名称:sphinx,代码行数:28,代码来源:quickstart.py


示例4: do_prompt

def do_prompt(d, key, text, default=None, validator=nonempty):
    while True:
        if default:
            prompt = purple(PROMPT_PREFIX + "%s [%s]: " % (text, default))
        else:
            prompt = purple(PROMPT_PREFIX + text + ": ")
        x = term_input(prompt).strip()
        if default and not x:
            x = default
        if not isinstance(x, unicode):
            # for Python 2.x, try to get a Unicode string out of it
            if x.decode("ascii", "replace").encode("ascii", "replace") != x:
                if TERM_ENCODING:
                    x = x.decode(TERM_ENCODING)
                else:
                    print turquoise(
                        "* Note: non-ASCII characters entered "
                        "and terminal encoding unknown -- assuming "
                        "UTF-8 or Latin-1."
                    )
                    try:
                        x = x.decode("utf-8")
                    except UnicodeDecodeError:
                        x = x.decode("latin1")
        try:
            x = validator(x)
        except ValidationError, err:
            print red("* " + str(err))
            continue
        break
开发者ID:karasusan,项目名称:sphinx-docs,代码行数:30,代码来源:quickstart.py


示例5: process_result

 def process_result(self, result):
     uri, docname, lineno, status, info, code = result
     if status == 'unchecked':
         return
     if status == 'working' and info != 'new':
         return
     if lineno:
         self.info('(line %4d) ' % lineno, nonl=1)
     if status == 'ignored':
         self.info(darkgray('-ignored- ') + uri)
     elif status == 'local':
         self.info(darkgray('-local-   ') + uri)
         self.write_entry('local', docname, lineno, uri)
     elif status == 'working':
         self.info(darkgreen('ok        ')  + uri)
     elif status == 'broken':
         self.info(red('broken    ') + uri + red(' - ' + info))
         self.write_entry('broken', docname, lineno, uri + ': ' + info)
         if self.app.quiet:
             self.warn('broken link: %s' % uri,
                       '%s:%s' % (self.env.doc2path(docname), lineno))
     elif status == 'redirected':
         text, color = {
             301: ('permanently', darkred),
             302: ('with Found', purple),
             303: ('with See Other', purple),
             307: ('temporarily', turquoise),
             0:   ('with unknown code', purple),
         }[code]
         self.write_entry('redirected ' + text, docname, lineno,
                          uri + ' to ' + info)
         self.info(color('redirect  ') + uri + color(' - ' + text + ' to '  + info))
开发者ID:4grim,项目名称:hackbright-django,代码行数:32,代码来源:linkcheck.py


示例6: run_apidoc

def run_apidoc(_):
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    proj_dir = os.path.abspath(os.path.join(cur_dir, '..', '..'))
    modules = ['larigira']
    exclude_files = [os.path.abspath(os.path.join(proj_dir, excl))
                     for excl in ('larigira/rpc.py', 'larigira/dbadmin/')]
    output_path = os.path.join(cur_dir, 'api')
    cmd_path = 'sphinx-apidoc'
    if hasattr(sys, 'real_prefix'):  # Are we in a virtualenv?
        # assemble the path manually
        cmd_path = os.path.abspath(os.path.join(sys.prefix,
                                                'bin',
                                                'sphinx-apidoc'))
    if not os.path.exists(cmd_path):
        print(red("No apidoc available!"), file=sys.stderr)
        return
    for module in modules:
        try:
            subprocess.check_call([cmd_path,
                                   '--force',
                                   '-o', output_path,
                                   module
                                   ] + exclude_files,
                                  cwd=proj_dir
                                 )
        except subprocess.CalledProcessError:
            print(red("APIdoc failed for module {}".format(module)))
开发者ID:boyska,项目名称:larigira,代码行数:27,代码来源:conf.py


示例7: summarize_failing_examples

def summarize_failing_examples(app, exception):
    """Collects the list of falling examples and prints them with a traceback.

    Raises ValueError if there where failing examples.
    """
    if exception is not None:
        return

    # Under no-plot Examples are not run so nothing to summarize
    if not app.config.sphinx_gallery_conf['plot_gallery']:
        return

    gallery_conf = app.config.sphinx_gallery_conf
    failing_examples = set(gallery_conf['failing_examples'].keys())
    expected_failing_examples = set(
        os.path.normpath(os.path.join(app.srcdir, path))
        for path in gallery_conf['expected_failing_examples'])

    examples_expected_to_fail = failing_examples.intersection(
        expected_failing_examples)
    if examples_expected_to_fail:
        logger.info("Examples failing as expected:", color='brown')
        for fail_example in examples_expected_to_fail:
            logger.info('%s failed leaving traceback:', fail_example)
            logger.info(gallery_conf['failing_examples'][fail_example])

    examples_not_expected_to_fail = failing_examples.difference(
        expected_failing_examples)
    fail_msgs = []
    if examples_not_expected_to_fail:
        fail_msgs.append(red("Unexpected failing examples:"))
        for fail_example in examples_not_expected_to_fail:
            fail_msgs.append(fail_example + ' failed leaving traceback:\n' +
                             gallery_conf['failing_examples'][fail_example] +
                             '\n')

    examples_not_expected_to_pass = expected_failing_examples.difference(
        failing_examples)
    # filter from examples actually run
    filename_pattern = gallery_conf.get('filename_pattern')
    examples_not_expected_to_pass = [
        src_file for src_file in examples_not_expected_to_pass
        if re.search(filename_pattern, src_file)]
    if examples_not_expected_to_pass:
        fail_msgs.append(red("Examples expected to fail, but not failing:\n") +
                         "Please remove these examples from\n" +
                         "sphinx_gallery_conf['expected_failing_examples']\n" +
                         "in your conf.py file"
                         "\n".join(examples_not_expected_to_pass))

    if fail_msgs:
        raise ValueError("Here is a summary of the problems encountered when "
                         "running the examples\n\n" + "\n".join(fail_msgs) +
                         "\n" + "-" * 79)
开发者ID:Titan-C,项目名称:sphinx-gallery,代码行数:54,代码来源:gen_gallery.py


示例8: check

    def check(self, node, docname):
        uri = node['refuri']

        if '#' in uri:
            uri = uri.split('#')[0]

        if uri in self.good:
            return

        lineno = None
        while lineno is None and node:
            node = node.parent
            lineno = node.line

        if uri[0:5] == 'http:' or uri[0:6] == 'https:':
            self.info(uri, nonl=1)

            if uri in self.broken:
                (r, s) = self.broken[uri]
            elif uri in self.redirected:
                (r, s) = self.redirected[uri]
            else:
                (r, s) = self.resolve(uri)

            if r == 0:
                self.info(' - ' + darkgreen('working'))
                self.good.add(uri)
            elif r == 2:
                self.info(' - ' + red('broken: ') + s)
                self.write_entry('broken', docname, lineno, uri + ': ' + s)
                self.broken[uri] = (r, s)
                if self.app.quiet:
                    self.warn('broken link: %s' % uri,
                              '%s:%s' % (self.env.doc2path(docname), lineno))
            else:
                self.info(' - ' + purple('redirected') + ' to ' + s)
                self.write_entry('redirected', docname,
                                 lineno, uri + ' to ' + s)
                self.redirected[uri] = (r, s)
        elif len(uri) == 0 or uri[0:7] == 'mailto:' or uri[0:4] == 'ftp:':
            return
        else:
            self.warn(uri + ' - ' + red('malformed!'))
            self.write_entry('malformed', docname, lineno, uri)
            if self.app.quiet:
                self.warn('malformed link: %s' % uri,
                          '%s:%s' % (self.env.doc2path(docname), lineno))
            self.app.statuscode = 1

        if self.broken:
            self.app.statuscode = 1
开发者ID:89sos98,项目名称:main,代码行数:51,代码来源:linkcheck.py


示例9: purge_module_apidoc

def purge_module_apidoc(sphinx, exception):
    # Short out if not supposed to run
    if not sphinx.config.clean_autogenerated_docs:
        return

    try:
        sphinx.info(bold('cleaning autogenerated docs... '), nonl=True)
        _doc_modules_path.ensure(dir=True)
        _doc_modules_path.remove(rec=True)
        sphinx.info(message='done')
    except Exception as ex:
        sphinx.info(red('failed to clean autogenerated docs'))
        sphinx.info(red(type(ex).__name__) + ' ', nonl=True)
        sphinx.info(str(ex))
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:14,代码来源:apidoc.py


示例10: do_prompt

def do_prompt(d, key, text, default=None, validator=nonempty):
    while True:
        if default:
            prompt = purple('> %s [%s]: ' % (text, default))
        else:
            prompt = purple('> ' + text + ': ')
        x = raw_input(prompt)
        if default and not x:
            x = default
        if validator and not validator(x):
            print red(" * " + validator.__doc__)
            continue
        break
    d[key] = x
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:14,代码来源:quickstart.py


示例11: do_prompt

def do_prompt(d, key, text, default=None, validator=nonempty):
    while True:
        if default is not None:
            prompt = PROMPT_PREFIX + "%s [%s]: " % (text, default)
        else:
            prompt = PROMPT_PREFIX + text + ": "
        if PY2:
            # for Python 2.x, try to get a Unicode string out of it
            if prompt.encode("ascii", "replace").decode("ascii", "replace") != prompt:
                if TERM_ENCODING:
                    prompt = prompt.encode(TERM_ENCODING)
                else:
                    print(
                        turquoise(
                            "* Note: non-ASCII default value provided "
                            "and terminal encoding unknown -- assuming "
                            "UTF-8 or Latin-1."
                        )
                    )
                    try:
                        prompt = prompt.encode("utf-8")
                    except UnicodeEncodeError:
                        prompt = prompt.encode("latin1")
        prompt = purple(prompt)
        x = term_input(prompt).strip()
        if default and not x:
            x = default
        x = term_decode(x)
        try:
            x = validator(x)
        except ValidationError as err:
            print(red("* " + str(err)))
            continue
        break
    d[key] = x
开发者ID:TimKam,项目名称:sphinx,代码行数:35,代码来源:quickstart.py


示例12: check_missing

 def check_missing(self):
     for mod in ModuleDocumenter.missing_modules:
         self.app.statuscode = 3
         print(ERR_MISSING.format(
             error=red(ERR),
             module=bold(mod),
         ))
开发者ID:celery,项目名称:sphinx_celery,代码行数:7,代码来源:apicheck.py


示例13: do_prompt

def do_prompt(text, default=None, validator=nonempty):
    # type: (str, str, Callable[[str], Any]) -> Union[str, bool]
    while True:
        if default is not None:
            prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default)
        else:
            prompt = PROMPT_PREFIX + text + ': '
        if USE_LIBEDIT:
            # Note: libedit has a problem for combination of ``input()`` and escape
            # sequence (see #5335).  To avoid the problem, all prompts are not colored
            # on libedit.
            pass
        else:
            prompt = colorize(COLOR_QUESTION, prompt, input_mode=True)
        x = term_input(prompt).strip()
        if default and not x:
            x = default
        x = term_decode(x)
        try:
            x = validator(x)
        except ValidationError as err:
            print(red('* ' + str(err)))
            continue
        break
    return x
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:25,代码来源:quickstart.py


示例14: do_prompt

def do_prompt(d, key, text, default=None, validator=nonempty):
    # type: (Dict, unicode, unicode, unicode, Callable[[unicode], Any]) -> None
    while True:
        if default is not None:
            prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default)  # type: unicode
        else:
            prompt = PROMPT_PREFIX + text + ': '
        if PY2:
            # for Python 2.x, try to get a Unicode string out of it
            if prompt.encode('ascii', 'replace').decode('ascii', 'replace') \
                    != prompt:
                if TERM_ENCODING:
                    prompt = prompt.encode(TERM_ENCODING)
                else:
                    print(turquoise('* Note: non-ASCII default value provided '
                                    'and terminal encoding unknown -- assuming '
                                    'UTF-8 or Latin-1.'))
                    try:
                        prompt = prompt.encode('utf-8')
                    except UnicodeEncodeError:
                        prompt = prompt.encode('latin1')
        prompt = purple(prompt)
        x = term_input(prompt).strip()
        if default and not x:
            x = default
        x = term_decode(x)
        try:
            x = validator(x)
        except ValidationError as err:
            print(red('* ' + str(err)))
            continue
        break
    d[key] = x
开发者ID:nvmanh,项目名称:plant,代码行数:33,代码来源:quickstart.py


示例15: visit_abjad_input_block

 def visit_abjad_input_block(self, node):
     try:
         print()
         message = bold(red('Found abjad_input_block.'))
         self.builder.warn(message, (self.builder.current_docname, node.line))
         print(systemtools.TestManager.clean_string(node.pformat()))
     except:
         traceback.print_exc()
     raise nodes.SkipNode
开发者ID:andrewyoung1991,项目名称:abjad,代码行数:9,代码来源:SphinxDocumentHandler.py


示例16: init

 def init(self):
     Builder.init(self)
     errors = False
     if not self.config.omegat_translated_path:
         self.info(red("'omegat_translated_path' should not be empty."))
         errors = True
     if not self.config.omegat_project_path:
         self.info(red("'omegat_project_path' should not be empty."))
         errors = True
     if self.config.omegat_translated_path not in self.config.locale_dirs:
         self.info(red("'omegat_translated_path' should be in locale_dirs."))
         errors = True
     if not self.config.language:
         self.info(red("'language' should be set."))
         errors = True
     if errors:
         self.info(red("    -> Please check conf.py"))
         raise RuntimeError("lack setting")
开发者ID:capnrefsmmat,项目名称:sphinx-contrib,代码行数:18,代码来源:compiler.py


示例17: visit_abjad_input_block

 def visit_abjad_input_block(self, node):
     try:
         #print()
         message = bold(red('Found abjad_input_block.'))
         self.builder.warn(message, (self.builder.current_docname, node.line))
         #print(stringtools.normalize(node.pformat()))
     except:
         traceback.print_exc()
     raise nodes.SkipNode
开发者ID:DnMllr,项目名称:abjad,代码行数:9,代码来源:SphinxDocumentHandler.py


示例18: handle_exception

def handle_exception(app, args, exception, stderr=sys.stderr):
    # type: (Sphinx, Any, Union[Exception, KeyboardInterrupt], IO) -> None
    if args.pdb:
        import pdb
        print(red(__('Exception occurred while building, starting debugger:')),
              file=stderr)
        traceback.print_exc()
        pdb.post_mortem(sys.exc_info()[2])
    else:
        print(file=stderr)
        if args.verbosity or args.traceback:
            traceback.print_exc(None, stderr)
            print(file=stderr)
        if isinstance(exception, KeyboardInterrupt):
            print(__('interrupted!'), file=stderr)
        elif isinstance(exception, SystemMessage):
            print(red(__('reST markup error:')), file=stderr)
            print(terminal_safe(exception.args[0]), file=stderr)
        elif isinstance(exception, SphinxError):
            print(red('%s:' % exception.category), file=stderr)
            print(terminal_safe(text_type(exception)), file=stderr)
        elif isinstance(exception, UnicodeError):
            print(red(__('Encoding error:')), file=stderr)
            print(terminal_safe(text_type(exception)), file=stderr)
            tbpath = save_traceback(app)
            print(red(__('The full traceback has been saved in %s, if you want '
                         'to report the issue to the developers.') % tbpath),
                  file=stderr)
        elif isinstance(exception, RuntimeError) and 'recursion depth' in str(exception):
            print(red(__('Recursion error:')), file=stderr)
            print(terminal_safe(text_type(exception)), file=stderr)
            print(file=stderr)
            print(__('This can happen with very large or deeply nested source '
                     'files.  You can carefully increase the default Python '
                     'recursion limit of 1000 in conf.py with e.g.:'), file=stderr)
            print(__('    import sys; sys.setrecursionlimit(1500)'), file=stderr)
        else:
            print(red(__('Exception occurred:')), file=stderr)
            print(format_exception_cut_frames().rstrip(), file=stderr)
            tbpath = save_traceback(app)
            print(red(__('The full traceback has been saved in %s, if you '
                         'want to report the issue to the developers.') % tbpath),
                  file=stderr)
            print(__('Please also report this if it was a user error, so '
                     'that a better error message can be provided next time.'),
                  file=stderr)
            print(__('A bug report can be filed in the tracker at '
                     '<https://github.com/sphinx-doc/sphinx/issues>. Thanks!'),
                  file=stderr)
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:49,代码来源:build.py


示例19: check

    def check(self, node, docname):
        uri = node["refuri"]

        if "#" in uri:
            uri = uri.split("#")[0]

        if uri in self.good:
            return

        lineno = None
        while lineno is None:
            node = node.parent
            if node is None:
                break
            lineno = node.line

        if len(uri) == 0 or uri[0:7] == "mailto:" or uri[0:4] == "ftp:":
            return

        if lineno:
            self.info("(line %3d) " % lineno, nonl=1)
        if uri[0:5] == "http:" or uri[0:6] == "https:":
            self.info(uri, nonl=1)

            if uri in self.broken:
                (r, s) = self.broken[uri]
            elif uri in self.redirected:
                (r, s) = self.redirected[uri]
            else:
                (r, s) = self.resolve(uri)

            if r == 0:
                self.info(" - " + darkgreen("working"))
                self.good.add(uri)
            elif r == 2:
                self.info(" - " + red("broken: ") + s)
                self.write_entry("broken", docname, lineno, uri + ": " + s)
                self.broken[uri] = (r, s)
                if self.app.quiet:
                    self.warn("broken link: %s" % uri, "%s:%s" % (self.env.doc2path(docname), lineno))
            else:
                self.info(" - " + purple("redirected") + " to " + s)
                self.write_entry("redirected", docname, lineno, uri + " to " + s)
                self.redirected[uri] = (r, s)
        else:
            self.info(uri + " - " + darkgray("local"))
            self.write_entry("local", docname, lineno, uri)

        if self.broken:
            self.app.statuscode = 1
开发者ID:asinghamgoodwin,项目名称:XLSForm-Debugger,代码行数:50,代码来源:linkcheck.py


示例20: process_result

 def process_result(self, result):
     # type: (Tuple[unicode, unicode, int, unicode, unicode, int]) -> None
     uri, docname, lineno, status, info, code = result
     if status == 'unchecked':
         return
     if status == 'working' and info == 'old':
         return
     if lineno:
         logger.info('(line %4d) ', lineno, nonl=1)
     if status == 'ignored':
         if info:
             logger.info(darkgray('-ignored- ') + uri + ': ' + info)
         else:
             logger.info(darkgray('-ignored- ') + uri)
     elif status == 'local':
         logger.info(darkgray('-local-   ') + uri)
         self.write_entry('local', docname, lineno, uri)
     elif status == 'working':
         logger.info(darkgreen('ok        ') + uri + info)
     elif status == 'broken':
         self.write_entry('broken', docname, lineno, uri + ': ' + info)
         if self.app.quiet or self.app.warningiserror:
             logger.warning('broken link: %s (%s)', uri, info,
                            location=(self.env.doc2path(docname), lineno))
         else:
             logger.info(red('broken    ') + uri + red(' - ' + info))
     elif status == 'redirected':
         text, color = {
             301: ('permanently', darkred),
             302: ('with Found', purple),
             303: ('with See Other', purple),
             307: ('temporarily', turquoise),
             0:   ('with unknown code', purple),
         }[code]
         self.write_entry('redirected ' + text, docname, lineno,
                          uri + ' to ' + info)
         logger.info(color('redirect  ') + uri + color(' - ' + text + ' to ' + info))
开发者ID:LFYG,项目名称:sphinx,代码行数:37,代码来源:linkcheck.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python docstrings.prepare_docstring函数代码示例发布时间:2022-05-27
下一篇:
Python console.nocolor函数代码示例发布时间: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