当前位置: 首页>>代码示例>>Python>>正文


Python formatter.AbstractFormatter类代码示例

本文整理汇总了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()
开发者ID:aw-bib,项目名称:tind-invenio,代码行数:12,代码来源:mailutils.py

示例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)
开发者ID:MinHuZ,项目名称:repo,代码行数:58,代码来源:help.py

示例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)
开发者ID:mynameismevin,项目名称:andromeda,代码行数:57,代码来源:help.py

示例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)
开发者ID:android,项目名称:tools_repo,代码行数:43,代码来源:help.py

示例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
开发者ID:MaxMorais,项目名称:Trail,代码行数:6,代码来源:table.py

示例6: __init__

      def __init__(self, gc):
        Coloring.__init__(self, gc, 'help')
        self.heading = self.printer('heading', attr='bold')

        self.wrap = AbstractFormatter(DumbWriter())
开发者ID:4455jkjh,项目名称:git-repo,代码行数:5,代码来源:help.py

示例7: __init__

            def __init__(self, gc):
                Coloring.__init__(self, gc, "help")
                self.heading = self.printer("heading", attr="bold")

                self.wrap = AbstractFormatter(DumbWriter())
开发者ID:MinHuZ,项目名称:repo,代码行数:5,代码来源:help.py

示例8: __init__

	def __init__(self):
		AbstractFormatter.__init__(self, NullWriter())
		self.m_raw = [ ]
		self.page_width = 60
		self.cursor = 0
开发者ID:andik,项目名称:robin,代码行数:5,代码来源:textformat.py


注:本文中的formatter.AbstractFormatter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。