本文整理汇总了Python中formatter.AbstractFormatter类的典型用法代码示例。如果您正苦于以下问题:Python AbstractFormatter类的具体用法?Python AbstractFormatter怎么用?Python AbstractFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractFormatter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: email_strip_html
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()
示例2: _Out
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)
示例3: _Out
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)
示例4: _Out
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)
示例5: new_formatter
def new_formatter(self):
formatter = AbstractFormatter(self._viewer)
# set parskip to prevent blank line at top of cell if the content
# starts with a <P> or header element.
formatter.parskip = 1
return formatter
示例6: __init__
def __init__(self, gc):
Coloring.__init__(self, gc, 'help')
self.heading = self.printer('heading', attr='bold')
self.wrap = AbstractFormatter(DumbWriter())
示例7: __init__
def __init__(self, gc):
Coloring.__init__(self, gc, "help")
self.heading = self.printer("heading", attr="bold")
self.wrap = AbstractFormatter(DumbWriter())
示例8: __init__
def __init__(self):
AbstractFormatter.__init__(self, NullWriter())
self.m_raw = [ ]
self.page_width = 60
self.cursor = 0