本文整理汇总了Python中docutils.frontend.OptionParser.get_default_values方法的典型用法代码示例。如果您正苦于以下问题:Python OptionParser.get_default_values方法的具体用法?Python OptionParser.get_default_values怎么用?Python OptionParser.get_default_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.frontend.OptionParser
的用法示例。
在下文中一共展示了OptionParser.get_default_values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_latex_document
# 需要导入模块: from docutils.frontend import OptionParser [as 别名]
# 或者: from docutils.frontend.OptionParser import get_default_values [as 别名]
def write_latex_document(self, latex_document_node,
all_latex_document_nodes):
output_filename = latex_document_node["multilatex-filename"]
variables = latex_document_node["multilatex-variables"]
content = latex_document_node["multilatex-content"]
options = latex_document_node["multilatex-options"]
docname = latex_document_node["multilatex-docname"]
doctree = latex_document_node["multilatex-doctree"]
if not output_filename.endswith(".tex"):
output_filename += ".tex"
self.info("processing {0}...".format(output_filename), nonl=1)
# for node in doctree.traverse(latex_document):
# node.parent.remove(node)
# parent_node = latex_document_node.parent
# parent_node.remove(latex_document_node)
self.post_process_images(doctree)
self.info("writing...", nonl=1)
docwriter = LaTeXWriter(self)
option_parser = OptionParser(
defaults=self.env.settings,
components=(docwriter,),
read_config_files=True)
doctree.settings = option_parser.get_default_values()
settings = doctree.settings
settings.contentsname = None
settings.docname = docname
for name, value in options.items():
setattr(settings, name, value)
settings.multilatex_options = options
settings.multilatex_variables = variables
settings.multilatex_content = content
settings.multilatex_output_filename = output_filename
settings.multilatex_all_latex_document_nodes = all_latex_document_nodes
destination = FileOutput(
destination_path=os.path.join(self.outdir, output_filename),
encoding="utf-8")
docwriter.write(doctree, destination)
self.info("done")
示例2: parse_testplan
# 需要导入模块: from docutils.frontend import OptionParser [as 别名]
# 或者: from docutils.frontend.OptionParser import get_default_values [as 别名]
def parse_testplan(source, parsed, is_spec,check_errors=False):
register_testplan_directives()
oldstderr = sys.stderr
docutils_out = StringIO.StringIO()
# sys.stderr = docutils_out
valid = True
reader_class=docutils.readers.get_reader_class("standalone")
reader=reader_class(None,"rst")
option_parser = OptionParser(
components=(reader.parser, reader),
defaults=[], read_config_files=1,
usage="", description="")
settings = option_parser.get_default_values()
# try:
reader.source = source
reader.settings = settings
reader.input = reader.source.read()
reader.document = doc = reader.new_document()
doc.parsed = parsed
doc.check_errors = check_errors
reader.parser.parse(reader.input, doc)
doc.current_source = doc.current_line = None
parsed = doc.parsed
# except:
# valid = False
# parsed = None
sys.stderr = oldstderr
err_msg = docutils_out.getvalue()
if 'feature' in parsed:
for f in parsed['feature']:
try:
f.from_spec
except:
f.from_spec = is_spec
return (valid and err_msg.find("ERROR") == -1), err_msg, parsed