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


Python AbstractFormatter.add_flowing_data方法代码示例

本文整理汇总了Python中formatter.AbstractFormatter.add_flowing_data方法的典型用法代码示例。如果您正苦于以下问题:Python AbstractFormatter.add_flowing_data方法的具体用法?Python AbstractFormatter.add_flowing_data怎么用?Python AbstractFormatter.add_flowing_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在formatter.AbstractFormatter的用法示例。


在下文中一共展示了AbstractFormatter.add_flowing_data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _Out

# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import add_flowing_data [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)
开发者ID:MinHuZ,项目名称:repo,代码行数:60,代码来源:help.py

示例2: _Out

# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import add_flowing_data [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)
开发者ID:mynameismevin,项目名称:andromeda,代码行数:59,代码来源:help.py

示例3: email_strip_html

# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import add_flowing_data [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()
开发者ID:aw-bib,项目名称:tind-invenio,代码行数:14,代码来源:mailutils.py

示例4: _Out

# 需要导入模块: from formatter import AbstractFormatter [as 别名]
# 或者: from formatter.AbstractFormatter import add_flowing_data [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)
开发者ID:android,项目名称:tools_repo,代码行数:45,代码来源:help.py


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