本文整理匯總了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