本文整理汇总了Python中misc.option函数的典型用法代码示例。如果您正苦于以下问题:Python option函数的具体用法?Python option怎么用?Python option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了option函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: pandoc_author
def pandoc_author(authors_and_institutions, auth2index,
inst2index, index2inst, auth2email):
# List authors on multiple lines
authors = []
for author, i, e in authors_and_institutions:
author = '**%s**' % author # set in boldface
if i is None:
authors.append(author)
else:
authors.append(author + ' at ' + ' and '.join(i))
plain_text = '### Author'
if len(authors) > 1:
plain_text += 's'
plain_text += '\n\n' + '\n\n'.join(authors) + '\n\n'
if option('strapdown'):
return plain_text
elif option('strict_markdown_output'):
return plain_text
elif option('multimarkdown_output'):
return 'Author: ' + ', '.join(authors) + '\n'
else:
# pandoc-extended markdown syntax
return '% ' + '; '.join(authors) + '\n'
开发者ID:sakhan007,项目名称:doconce,代码行数:25,代码来源:pandoc.py
示例2: __init__
def __init__(self):
self.tracks = os.listdir(option("music-dir"))
if option("music-shuffle"):
random.shuffle(self.tracks)
self.track = 0
pygame.mixer.music.set_endevent(Music.MUSIC_FINISHED)
开发者ID:zevlg,项目名称:py-sealhunter,代码行数:7,代码来源:music.py
示例3: pandoc_date
def pandoc_date(m):
date = m.group("subst")
if option("strapdown"):
return "#### Date: " + date
elif option("strict_markdown_output"):
return "#### Date: " + date
elif option("multimarkdown_output"):
return "Date: " + date + "\n"
else:
# pandoc-extended markdown syntax
return "% " + date + "\n"
开发者ID:dragly,项目名称:doconce,代码行数:11,代码来源:pandoc.py
示例4: pandoc_title
def pandoc_title(m):
title = m.group('subst')
if option('strapdown'):
# title is in <title> tag in INTRO for the header of the HTML output
return ''
elif option('strict_markdown_output'):
return '# ' + title
elif option('multimarkdown_output'):
return 'Title: ' + title
else:
return '% ' + title
开发者ID:ahmadia,项目名称:doconce,代码行数:11,代码来源:pandoc.py
示例5: pandoc_title
def pandoc_title(m):
title = m.group("subst")
if option("strapdown"):
# title is in <title> tag in INTRO for the header of the HTML output
return ""
elif option("strict_markdown_output"):
return "# " + title
elif option("multimarkdown_output"):
return "Title: " + title
else:
# pandoc-extended markdown syntax
return "% " + title
开发者ID:dragly,项目名称:doconce,代码行数:12,代码来源:pandoc.py
示例6: pandoc_linebreak
def pandoc_linebreak(m):
# orig: r'\g<text>\\n',
text = m.group("text")
if option("github_md"):
return text + "<br />"
else:
return text + r"\n"
开发者ID:dragly,项目名称:doconce,代码行数:7,代码来源:pandoc.py
示例7: rst_abstract
def rst_abstract(m):
# r'\n*\g<type>.* \g<text>\n\g<rest>'
name = m.group('type').strip()
text = m.group('text').strip()
rest = m.group('rest').strip()
if option('rst_uio'):
s = """
.. uio-introduction::
%s
.. contents::
.. section-numbering::
%s
""" % (indent_lines(text, 'rst'), rest)
return s
else:
if name.lower() == 'preface':
# Drop heading (short abstract for books)
return '\n%(text)s\n\n%(rest)s' % vars()
else:
return '\n*%(name)s.* %(text)s\n\n%(rest)s' % vars()
开发者ID:KGHustad,项目名称:doconce,代码行数:26,代码来源:rst.py
示例8: rst_author
def rst_author(authors_and_institutions, auth2index,
inst2index, index2inst, auth2email):
if option('rst_uio'):
if authors_and_institutions:
# Use first author and email
responsible = authors_and_institutions[0][0]
email = authors_and_institutions[0][2]
text = """
.. uio-meta::
:responsible-name: %s
""" % responsible
if email:
text += ' :responsible-email: %s\n\n' % email
else:
errwarn('*** error: with --rst_uio there must be an AUTHOR:')
errwarn(' field with (at least) one author w/email who will be')
errwarn(' listed as the resposible under uio-meta::')
_abort()
else:
authors = []
for author, i, email in authors_and_institutions:
if email:
email = email.replace('@', ' at ')
authors.append(author + ' (%s)' % email)
else:
authors.append(author)
text = ':Authors: ' + ', '.join(authors) # (text is already r-stripped in typeset_authors)
# we skip institutions in rst
return text
开发者ID:KGHustad,项目名称:doconce,代码行数:30,代码来源:rst.py
示例9: sphinx_movie
def sphinx_movie(m):
filename = m.group("filename")
special_movie = (
"*" in filename
or "->" in filename
or "youtu.be" in filename
or "youtube.com" in filename
or "vimeo.com" in filename
)
if option("runestone") and not special_movie:
# Use RunestoneInteractive video environment
global video_counter
video_counter += 1
text = """
.. video:: video_%d
:controls:
%s
""" % (
video_counter,
filename,
)
return text
else:
# Use plain html code
return rst_movie(m)
开发者ID:dragly,项目名称:doconce,代码行数:26,代码来源:sphinx.py
示例10: xml_movie
def xml_movie(m):
filename = m.group('filename').srip()
opts = m.group('options').strip()
caption = m.group('caption').strip()
if opts:
opts = [s.split('=') for s in opts.split()]
opts = ['%s="%s"' % (key, value) for key, value in opts]
opts = ' ' + ' '.join(opts)
else:
opts = ''
autoplay = option('html_video_autoplay=', 'False')
if autoplay in ('on', 'off', 'True', 'true'):
autoplay = True
else:
autoplay = False
if opts:
opts.append('autoplay="%s"' % str(autoplay))
text = '<figure filename="%s%s>' % (filename, opts)
if caption:
text += '\n<caption>\n%s\n</caption>' % caption
text += '\n</figure>\n'
return text
开发者ID:apetcho,项目名称:doconce,代码行数:25,代码来源:xml.py
示例11: rst_abstract
def rst_abstract(m):
# r'\n*\g<type>.* \g<text>\n\g<rest>'
name = m.group("type").strip()
text = m.group("text").strip()
rest = m.group("rest").strip()
if option("rst_uio"):
s = """
.. uio-introduction::
%s
.. contents::
.. section-numbering::
%s
""" % (
indent_lines(text, "rst"),
rest,
)
return s
else:
return "\n*%(name)s.* %(text)s\n\n%(rest)s" % vars()
开发者ID:sjsrey,项目名称:doconce,代码行数:25,代码来源:rst.py
示例12: rst_author
def rst_author(authors_and_institutions, auth2index, inst2index, index2inst, auth2email):
if option("rst_uio"):
if authors_and_institutions:
# Use first author and email
responsible = authors_and_institutions[0][0]
email = authors_and_institutions[0][2]
text = (
"""
.. uio-meta::
:responsible-name: %s
"""
% responsible
)
if email:
text += " :responsible-email: %s\n\n" % email
else:
print "*** error: with --rst_uio there must be an AUTHOR:"
print " field with (at least) one author w/email who will be"
print " listed as the resposible under uio-meta::"
_abort()
else:
authors = []
for author, i, email in authors_and_institutions:
if email:
email = email.replace("@", " at ")
authors.append(author + " (%s)" % email)
else:
authors.append(author)
text = ":Authors: " + ", ".join(authors) # (text is already r-stripped in typeset_authors)
# we skip institutions in rst
return text
开发者ID:sjsrey,项目名称:doconce,代码行数:32,代码来源:rst.py
示例13: plain_quiz
def plain_quiz(quiz):
# Simple typesetting of a quiz
import string
question_prefix = quiz.get("question prefix", option("quiz_question_prefix=", "Question:"))
common_choice_prefix = option("quiz_choice_prefix=", "Choice")
quiz_expl = option("quiz_explanations=", "on")
text = "\n\n"
if "new page" in quiz:
text += "======= %s =======\n\n" % (quiz["new page"])
# Don't write Question: ... if inside an exercise section
if quiz.get("embedding", "None") in ["exercise"]:
pass
else:
text += "\n"
if question_prefix:
text += "%s " % (question_prefix)
text += quiz["question"] + "\n\n"
# List choices as paragraphs
for i, choice in enumerate(quiz["choices"]):
# choice_no = i+1
choice_no = string.ascii_uppercase[i]
answer = choice[0].capitalize() + "!"
choice_prefix = common_choice_prefix
if "choice prefix" in quiz:
if isinstance(quiz["choice prefix"][i], basestring):
choice_prefix = quiz["choice prefix"][i]
if choice_prefix == "" or choice_prefix[-1] in [".", ":", "?"]:
pass # don't add choice number/letter
else:
choice_prefix += " %s:" % choice_no
# Let choice start with a newline if pure code starts the choice
# (test for different code block types so this function can work
# for other formats too...)
choice = choice[1].lstrip()
code_starters = "Code::", "~~~", "```", "{{{"
for code_starter in code_starters:
if choice.startswith(code_starter):
choice = "\n" + choice
# Cannot treat explanations
text += "%s %s\n\n" % (choice_prefix, choice)
return text
开发者ID:KGHustad,项目名称:doconce,代码行数:47,代码来源:plaintext.py
示例14: plain_quiz
def plain_quiz(quiz):
# Simple typesetting of a quiz
import string
question_prefix = quiz.get('question prefix',
option('quiz_question_prefix=', 'Question:'))
common_choice_prefix = option('quiz_choice_prefix=', 'Choice')
quiz_expl = option('quiz_explanations=', 'on')
text = '\n\n'
if 'new page' in quiz:
text += '======= %s =======\n\n' % (quiz['new page'])
# Don't write Question: ... if inside an exercise section
if quiz.get('embedding', 'None') in ['exercise',]:
pass
else:
text += '\n'
if question_prefix:
text += '%s ' % (question_prefix)
text += quiz['question'] + '\n\n'
# List choices as paragraphs
for i, choice in enumerate(quiz['choices']):
#choice_no = i+1
choice_no = string.ascii_uppercase[i]
answer = choice[0].capitalize() + '!'
choice_prefix = common_choice_prefix
if 'choice prefix' in quiz:
if isinstance(quiz['choice prefix'][i], basestring):
choice_prefix = quiz['choice prefix'][i]
if choice_prefix == '' or choice_prefix[-1] in ['.', ':', '?']:
pass # don't add choice number/letter
else:
choice_prefix += ' %s:' % choice_no
# Let choice start with a newline if pure code starts the choice
# (test for different code block types so this function can work
# for other formats too...)
choice = choice[1].lstrip()
code_starters = 'Code::', '~~~', '```', '{{{'
for code_starter in code_starters:
if choice.startswith(code_starter):
choice = '\n' + choice
# Cannot treat explanations
text += '%s %s\n\n' % (choice_prefix, choice)
return text
开发者ID:apetcho,项目名称:doconce,代码行数:47,代码来源:plaintext.py
示例15: sphinx_ref_and_label
def sphinx_ref_and_label(section_label2title, format, filestr):
# Special fix early in the process:
# Deal with !split - by default we place splits before
# the all the topmost sections
# (This must be done before labels are put above section
# headings)
if '!split' in filestr and not option('sphinx_keep_splits'):
print '*** warning: new !split inserted (override all existing !split)'
# Note: the title is at this stage translated to a chapter heading!
# This title/heading must be removed for the algorithm below to work
# (remove it, then insert afterwards)
pattern = r'^.. Document title:\n\n={3,9}.+?={3,9}'
m = re.search(pattern, filestr, flags=re.MULTILINE)
title_replacement = '<<<<<<<DOCUMENT TITLE>>>>>>>>>>>>' # "unlikely" str
if m:
title = m.group()
filestr = filestr.replace(title, title_replacement)
else:
title = ''
topmost_section = 0
for i in [9, 7, 5]:
if re.search(r'^%s' % ('='*i), filestr, flags=re.MULTILINE):
topmost_section = i
print ' before every %s heading %s' % \
('='*topmost_section, '='*topmost_section)
print ' because this strategy gives a well-functioning'
print ' table of contents in Sphinx'
print ' (use --sphinx_keep_splits to enforce your own !split commands)'
break
if topmost_section:
# First remove all !split
filestr = re.sub(r'^!split *\n', '', filestr, flags=re.MULTILINE)
# Insert new splits before all topmost sections
pattern = r'^%s (.+?) %s' % \
('='*topmost_section, '='*topmost_section)
lines = filestr.splitlines()
for i in range(len(lines)):
if re.search(pattern, lines[i]):
lines[i] = '!split\n' + lines[i]
filestr = '\n'.join(lines)
filestr = filestr.replace(title_replacement, title)
filestr = ref_and_label_commoncode(section_label2title, format, filestr)
# replace all references to sections:
for label in section_label2title:
filestr = filestr.replace('ref{%s}' % label, ':ref:`%s`' % label)
# Not of interest after sphinx got equation references:
#from common import ref2equations
#filestr = ref2equations(filestr)
# Replace remaining ref{x} as :ref:`x`
filestr = re.sub(r'ref\{(.+?)\}', ':ref:`\g<1>`', filestr)
return filestr
开发者ID:apetcho,项目名称:doconce,代码行数:58,代码来源:sphinx.py
示例16: pandoc_quiz
def pandoc_quiz(quiz):
# Simple typesetting of a quiz
import string
question_prefix = quiz.get('question prefix',
option('quiz_question_prefix=', 'Question:'))
common_choice_prefix = option('quiz_choice_prefix=', 'Choice')
quiz_expl = option('quiz_explanations=', 'on')
text = '\n\n'
if 'new page' in quiz:
text += '## %s\n\n' % (quiz['new page'])
# Don't write Question: ... if inside an exercise section
if quiz.get('embedding', 'None') in ['exercise',]:
pass
else:
text += '\n'
if question_prefix:
text += '**%s** ' % (question_prefix)
text += quiz['question'] + '\n\n'
# List choices as paragraphs
for i, choice in enumerate(quiz['choices']):
#choice_no = i+1
choice_no = string.ascii_uppercase[i]
answer = choice[0].capitalize() + '!'
choice_prefix = common_choice_prefix
if 'choice prefix' in quiz:
if isinstance(quiz['choice prefix'][i], basestring):
choice_prefix = quiz['choice prefix'][i]
if choice_prefix == '' or choice_prefix[-1] in ['.', ':', '?']:
pass # don't add choice number/letter
else:
choice_prefix += ' %s:' % choice_no
if choice_prefix:
choice_prefix = '**%s**' % choice_prefix
# Always have a newline after choice in case code or tex
# blocks appear first
choice_prefix = choice_prefix + '\n'
# Cannot treat explanations and answers
text += '%s %s\n\n' % (choice_prefix, choice[1])
return text
开发者ID:sakhan007,项目名称:doconce,代码行数:44,代码来源:pandoc.py
示例17: pandoc_quiz
def pandoc_quiz(quiz):
# Simple typesetting of a quiz
import string
question_prefix = quiz.get("question prefix", option("quiz_question_prefix=", "Question:"))
common_choice_prefix = option("quiz_choice_prefix=", "Choice")
quiz_expl = option("quiz_explanations=", "on")
text = "\n\n"
if "new page" in quiz:
text += "## %s\n\n" % (quiz["new page"])
# Don't write Question: ... if inside an exercise section
if quiz.get("embedding", "None") in ["exercise"]:
pass
else:
text += "\n"
if question_prefix:
text += "**%s** " % (question_prefix)
text += quiz["question"] + "\n\n"
# List choices as paragraphs
for i, choice in enumerate(quiz["choices"]):
# choice_no = i+1
choice_no = string.ascii_uppercase[i]
answer = choice[0].capitalize() + "!"
choice_prefix = common_choice_prefix
if "choice prefix" in quiz:
if isinstance(quiz["choice prefix"][i], basestring):
choice_prefix = quiz["choice prefix"][i]
if choice_prefix == "" or choice_prefix[-1] in [".", ":", "?"]:
pass # don't add choice number/letter
else:
choice_prefix += " %s:" % choice_no
if choice_prefix:
choice_prefix = "**%s**" % choice_prefix
# Always have a newline after choice in case code or tex
# blocks appear first
choice_prefix = choice_prefix + "\n"
# Cannot treat explanations and answers
text += "%s %s\n\n" % (choice_prefix, choice[1])
return text
开发者ID:dragly,项目名称:doconce,代码行数:44,代码来源:pandoc.py
示例18: sphinx_ref_and_label
def sphinx_ref_and_label(section_label2title, format, filestr):
# Special fix early in the process:
# Deal with !split - by default we place splits before
# the all the topmost sections
# (This must be done before labels are put above section
# headings)
if "!split" in filestr and not option("sphinx_keep_splits"):
errwarn("*** warning: new !split inserted (override all existing !split)")
# Note: the title is at this stage translated to a chapter heading!
# This title/heading must be removed for the algorithm below to work
# (remove it, then insert afterwards)
pattern = r"^.. Document title:\n\n={3,9}.+?={3,9}"
m = re.search(pattern, filestr, flags=re.MULTILINE)
title_replacement = "<<<<<<<DOCUMENT TITLE>>>>>>>>>>>>" # "unlikely" str
if m:
title = m.group()
filestr = filestr.replace(title, title_replacement)
else:
title = ""
topmost_section = 0
for i in [9, 7, 5]:
if re.search(r"^%s" % ("=" * i), filestr, flags=re.MULTILINE):
topmost_section = i
errwarn(" before every %s heading %s" % ("=" * topmost_section, "=" * topmost_section))
errwarn(" because this strategy gives a well-functioning")
errwarn(" table of contents in Sphinx")
errwarn(" (use --sphinx_keep_splits to enforce your own !split commands)")
break
if topmost_section:
# First remove all !split
filestr = re.sub(r"^!split *\n", "", filestr, flags=re.MULTILINE)
# Insert new splits before all topmost sections
pattern = r"^%s (.+?) %s" % ("=" * topmost_section, "=" * topmost_section)
lines = filestr.splitlines()
for i in range(len(lines)):
if re.search(pattern, lines[i]):
lines[i] = "!split\n" + lines[i]
filestr = "\n".join(lines)
filestr = filestr.replace(title_replacement, title)
filestr = ref_and_label_commoncode(section_label2title, format, filestr)
# replace all references to sections:
for label in section_label2title:
filestr = filestr.replace("ref{%s}" % label, ":ref:`%s`" % label)
# Not of interest after sphinx got equation references:
# from common import ref2equations
# filestr = ref2equations(filestr)
# Replace remaining ref{x} as :ref:`x`
filestr = re.sub(r"ref\{(.+?)\}", ":ref:`\g<1>`", filestr)
return filestr
开发者ID:dragly,项目名称:doconce,代码行数:56,代码来源:sphinx.py
示例19: pandoc_table
def pandoc_table(table):
if option('github_md'):
text = html_table(table)
# Fix the problem that `verbatim` inside the table is not
# typeset as verbatim (according to the pandoc translator rules)
# in the GitHub Issue Tracker
text = re.sub(r'`([^`]+?)`', '<code>\g<1></code>', text)
return text
# else: Pandoc-extended Markdown syntax
"""
Simple markdown tables look like this::
Left Right Center Default
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
"""
# Slight modification of rst_table
column_width = table_analysis(table['rows'])
ncolumns = len(column_width)
column_spec = table.get('columns_align', 'c'*ncolumns).replace('|', '')
heading_spec = table.get('headings_align', 'c'*ncolumns).replace('|', '')
a2py = {'r': 'rjust', 'l': 'ljust', 'c': 'center'}
s = '' # '\n'
for i, row in enumerate(table['rows']):
#s += ' ' # indentation of tables
if row == ['horizontal rule'] and i > 0 and i < len(table['rows'])-1:
# No horizontal rule at the top and bottom, just after heading
for w in column_width:
s += '-'*w + ' '
else:
# check if this is a headline between two horizontal rules:
if i == 1 and \
table['rows'][i-1] == ['horizontal rule'] and \
table['rows'][i+1] == ['horizontal rule']:
headline = True
else:
headline = False
for w, c, ha, ca in \
zip(column_width, row, heading_spec, column_spec):
if headline:
s += getattr(c, a2py[ha])(w) + ' '
elif row != ['horizontal rule']:
s += getattr(c, a2py[ca])(w) + ' '
s += '\n'
s += '\n'
return s
开发者ID:sakhan007,项目名称:doconce,代码行数:54,代码来源:pandoc.py
示例20: pandoc_table
def pandoc_table(table):
if option("github_md"):
text = html_table(table)
# Fix the problem that `verbatim` inside the table is not
# typeset as verbatim (according to the pandoc translator rules)
# in the GitHub Issue Tracker
text = re.sub(r"`([^`]+?)`", "<code>\g<1></code>", text)
return text
# else: Pandoc-extended Markdown syntax
"""
Simple markdown tables look like this::
Left Right Center Default
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
"""
# Slight modification of rst_table
column_width = table_analysis(table["rows"])
ncolumns = len(column_width)
column_spec = table.get("columns_align", "c" * ncolumns).replace("|", "")
heading_spec = table.get("headings_align", "c" * ncolumns).replace("|", "")
a2py = {"r": "rjust", "l": "ljust", "c": "center"}
s = "" # '\n'
for i, row in enumerate(table["rows"]):
# s += ' ' # indentation of tables
if row == ["horizontal rule"] and i > 0 and i < len(table["rows"]) - 1:
# No horizontal rule at the top and bottom, just after heading
for w in column_width:
s += "-" * w + " "
else:
# check if this is a headline between two horizontal rules:
if i == 1 and table["rows"][i - 1] == ["horizontal rule"] and table["rows"][i + 1] == ["horizontal rule"]:
headline = True
else:
headline = False
for w, c, ha, ca in zip(column_width, row, heading_spec, column_spec):
if headline:
s += getattr(c, a2py[ha])(w) + " "
elif row != ["horizontal rule"]:
s += getattr(c, a2py[ca])(w) + " "
s += "\n"
s += "\n"
return s
开发者ID:dragly,项目名称:doconce,代码行数:51,代码来源:pandoc.py
注:本文中的misc.option函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论