本文整理汇总了Python中docutils.nodes.system_message方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.system_message方法的具体用法?Python nodes.system_message怎么用?Python nodes.system_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.system_message方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def apply(self):
pending = self.startnode
parent = pending.parent
child = pending
while parent:
# Check for appropriate following siblings:
for index in range(parent.index(child) + 1, len(parent)):
element = parent[index]
if (isinstance(element, nodes.Invisible) or
isinstance(element, nodes.system_message)):
continue
element['classes'] += pending.details['class']
pending.parent.remove(pending)
return
else:
# At end of section or container; apply to sibling
child = parent
parent = parent.parent
error = self.document.reporter.error(
'No suitable element following "%s" directive'
% pending.details['directive'],
nodes.literal_block(pending.rawsource, pending.rawsource),
line=pending.line)
pending.replace_self(error)
示例2: system_message
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def system_message(self, level, message, *children, **kwargs):
self.messages.append((level, message, children, kwargs))
return nodes.system_message(message, level=level,
type=self.levels[level],
*children, **kwargs)
示例3: apply
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def apply(self):
for node in self.document.traverse(nodes.system_message):
if node['level'] < self.document.reporter.report_level:
node.parent.remove(node)
示例4: __init__
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def __init__(self, system_message, level):
Exception.__init__(self, system_message.astext())
self.level = level
示例5: attach_observer
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def attach_observer(self, observer):
"""
The `observer` parameter is a function or bound method which takes one
argument, a `nodes.system_message` instance.
"""
self.observers.append(observer)
示例6: debug
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def debug(self, *args, **kwargs):
"""
Level-0, "DEBUG": an internal reporting issue. Typically, there is no
effect on the processing. Level-0 system messages are handled
separately from the others.
"""
if self.debug_flag:
return self.system_message(self.DEBUG_LEVEL, *args, **kwargs)
示例7: info
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def info(self, *args, **kwargs):
"""
Level-1, "INFO": a minor issue that can be ignored. Typically there is
no effect on processing, and level-1 system messages are not reported.
"""
return self.system_message(self.INFO_LEVEL, *args, **kwargs)
示例8: warning
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def warning(self, *args, **kwargs):
"""
Level-2, "WARNING": an issue that should be addressed. If ignored,
there may be unpredictable problems with the output.
"""
return self.system_message(self.WARNING_LEVEL, *args, **kwargs)
示例9: error
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def error(self, *args, **kwargs):
"""
Level-3, "ERROR": an error that should be addressed. If ignored, the
output will contain errors.
"""
return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
示例10: severe
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def severe(self, *args, **kwargs):
"""
Level-4, "SEVERE": a severe error that must be addressed. If ignored,
the output will contain severe errors. Typically level-4 system
messages are turned into exceptions which halt processing.
"""
return self.system_message(self.SEVERE_LEVEL, *args, **kwargs)
示例11: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import system_message [as 别名]
def run(self):
if not isinstance(self.state, states.SubstitutionDef):
raise self.error(
'Invalid context: the "%s" directive can only be used within '
'a substitution definition.' % self.name)
self.assert_has_content()
text = '\n'.join(self.content)
element = nodes.Element(text)
self.state.nested_parse(self.content, self.content_offset,
element)
# element might contain [paragraph] + system_message(s)
node = None
messages = []
for elem in element:
if not node and isinstance(elem, nodes.paragraph):
node = elem
elif isinstance(elem, nodes.system_message):
elem['backrefs'] = []
messages.append(elem)
else:
return [
self.state_machine.reporter.error(
'Error in "%s" directive: may contain a single paragraph '
'only.' % (self.name), line=self.lineno) ]
if node:
return messages + node.children
return messages