本文整理汇总了Python中sphinx.util.console.red函数的典型用法代码示例。如果您正苦于以下问题:Python red函数的具体用法?Python red怎么用?Python red使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了red函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
示例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")
示例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
示例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
示例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))
示例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)))
示例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)
示例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
示例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))
示例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
示例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
示例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),
))
示例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
示例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
示例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