示例#1
0
文件: help.py 项目: MinHuZ/repo
        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
0
文件: help.py 项目: liaods/git-repo
        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
0
        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
0
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()
示例#5
0
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()
示例#6
0
文件: help.py 项目: oux/google-repo
        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%s', header_prefix, 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('%s%s', header_prefix, m.group(1))
                        self.nl()
                        self.nl()
                        continue

                    self.wrap.add_flowing_data(para)
                    self.wrap.end_paragraph(1)
                self.wrap.end_paragraph(0)
示例#7
0
    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)