本文整理汇总了Python中formatter.AbstractFormatter.end_paragraph方法的典型用法代码示例。如果您正苦于以下问题:Python AbstractFormatter.end_paragraph方法的具体用法?Python AbstractFormatter.end_paragraph怎么用?Python AbstractFormatter.end_paragraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formatter.AbstractFormatter
的用法示例。
在下文中一共展示了AbstractFormatter.end_paragraph方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _Out
# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import end_paragraph [as 别名]
class _Out(Coloring):
def __init__(self, gc):
Coloring.__init__(self, gc, "help")
self.heading = self.printer("heading", attr="bold")
self.wrap = AbstractFormatter(DumbWriter())
def _PrintSection(self, heading, bodyAttr):
try:
body = getattr(cmd, bodyAttr)
except AttributeError:
return
if body == "" or body is None:
return
self.nl()
self.heading("%s", heading)
self.nl()
self.heading("%s", "".ljust(len(heading), "-"))
self.nl()
me = "repo %s" % cmd.NAME
body = body.strip()
body = body.replace("%prog", me)
asciidoc_hdr = re.compile(r"^\n?([^\n]{1,})\n([=~-]{2,})$")
for para in body.split("\n\n"):
if para.startswith(" "):
self.write("%s", para)
self.nl()
self.nl()
continue
m = asciidoc_hdr.match(para)
if m:
title = m.group(1)
section_type = m.group(2)
if section_type[0] in ("=", "-"):
p = self.heading
else:
def _p(fmt, *args):
self.write(" ")
self.heading(fmt, *args)
p = _p
p("%s", title)
self.nl()
p("%s", "".ljust(len(title), section_type[0]))
self.nl()
continue
self.wrap.add_flowing_data(para)
self.wrap.end_paragraph(1)
self.wrap.end_paragraph(0)
示例2: _Out
# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import end_paragraph [as 别名]
class _Out(Coloring):
def __init__(self, gc):
Coloring.__init__(self, gc, 'help')
self.heading = self.printer('heading', attr='bold')
self.wrap = AbstractFormatter(DumbWriter())
def _PrintSection(self, heading, bodyAttr):
try:
body = getattr(cmd, bodyAttr)
except AttributeError:
return
if body == '' or body is None:
return
self.nl()
self.heading('%s', heading)
self.nl()
self.heading('%s', ''.ljust(len(heading), '-'))
self.nl()
me = 'andromeda %s' % cmd.NAME
body = body.strip()
body = body.replace('%prog', me)
asciidoc_hdr = re.compile(r'^\n?([^\n]{1,})\n([=~-]{2,})$')
for para in body.split("\n\n"):
if para.startswith(' '):
self.write('%s', para)
self.nl()
self.nl()
continue
m = asciidoc_hdr.match(para)
if m:
title = m.group(1)
section_type = m.group(2)
if section_type[0] in ('=', '-'):
p = self.heading
else:
def _p(fmt, *args):
self.write(' ')
self.heading(fmt, *args)
p = _p
p('%s', title)
self.nl()
p('%s', ''.ljust(len(title), section_type[0]))
self.nl()
continue
self.wrap.add_flowing_data(para)
self.wrap.end_paragraph(1)
self.wrap.end_paragraph(0)
示例3: email_strip_html
# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import end_paragraph [as 别名]
def email_strip_html(html_content):
"""Strip html tags from html_content, trying to respect formatting."""
html_content = RE_SPACES.sub(' ', html_content)
html_content = RE_NEWLINES.sub('\n', html_content)
html_content = RE_HTML_TAGS.sub('', html_content)
html_content = html_content.split('\n')
out = StringIO()
out_format = AbstractFormatter(DumbWriter(out))
for row in html_content:
out_format.add_flowing_data(row)
out_format.end_paragraph(1)
return out.getvalue()
示例4: _Out
# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import end_paragraph [as 别名]
class _Out(Coloring):
def __init__(self, gc):
Coloring.__init__(self, gc, 'help')
self.heading = self.printer('heading', attr='bold')
self.wrap = AbstractFormatter(DumbWriter())
def _PrintSection(self, heading, bodyAttr):
try:
body = getattr(cmd, bodyAttr)
except AttributeError:
return
if body == '' or body is None:
return
self.nl()
self.heading('%s', heading)
self.nl()
self.nl()
me = 'repo %s' % cmd.NAME
body = body.strip()
body = body.replace('%prog', me)
asciidoc_hdr = re.compile(r'^\n?#+ (.+)$')
for para in body.split("\n\n"):
if para.startswith(' '):
self.write('%s', para)
self.nl()
self.nl()
continue
m = asciidoc_hdr.match(para)
if m:
self.heading(m.group(1))
self.nl()
self.nl()
continue
self.wrap.add_flowing_data(para)
self.wrap.end_paragraph(1)
self.wrap.end_paragraph(0)