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


Python formatter.FormatterBase类代码示例

本文整理汇总了Python中MoinMoin.formatter.FormatterBase的典型用法代码示例。如果您正苦于以下问题:Python FormatterBase类的具体用法?Python FormatterBase怎么用?Python FormatterBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, request, **kw):
        FormatterBase.__init__(self, request, **kw)

        self.document = minidom.Document()
        self.document.documentElement = self.document.createElement('xml')
        self.position = self.document.documentElement
        self.tag_stack = [('xml', {})]
开发者ID:steveyen,项目名称:moingo,代码行数:7,代码来源:dom_xml.py

示例2: paragraph

 def paragraph(self, on, **kw):
     # Maintain the accessible flag `in_p`
     FormatterBase.paragraph(self, on)
     if on:
         return self._output()
     else:
         return self._output_EOL_BLK()
开发者ID:dwf,项目名称:moin2rst,代码行数:7,代码来源:text_x-rst.py

示例3: pagelink

 def pagelink(self, on, pagename="", page=None, **kw):
     FormatterBase.pagelink(self, on, pagename, page, **kw)
     if page is None:
         page = Page(self.request, pagename, formatter=self)
     link_text = page.link_to(self.request, on=on, **kw)
     self._curr.xml_append(tree.text(U(link_text)))
     return ""
开发者ID:pombredanne,项目名称:akara,代码行数:7,代码来源:application_xml.py

示例4: paragraph

 def paragraph(self, on, **kw):
     FormatterBase.paragraph(self, on)
     if on:
         self.paragraph_begin()
     else:
         self.paragraph_end()
     return ''
开发者ID:IvanLogvinov,项目名称:soar,代码行数:7,代码来源:text_plain.py

示例5: __init__

    def __init__(self, request, **kw):
        FormatterBase.__init__(self, request, **kw)

        self.members = []
        self._bullet_list_level = 0
        self._inside_link = False
        self._new_member = ''
开发者ID:IvanLogvinov,项目名称:soar,代码行数:7,代码来源:groups.py

示例6: preformatted

 def preformatted(self, on, **kw):
     FormatterBase.preformatted(self, on)
     snip = u'---%<'
     snip = snip + (u'-' * (78 - len(snip)))
     if on:
         return u'\n' + snip + u'\n'
     else:
         return snip + u'\n'
开发者ID:steveyen,项目名称:moingo,代码行数:8,代码来源:text_plain.py

示例7: macro

    def macro(self, macro_obj, name, args, markup=None):
        """As far as the DocBook formatter is concerned there are three
        kinds of macros: Bad, Handled and Unknown.

        The Bad ones are the ones that are known not to work, and are on its
        blacklist. They will be ignored and an XML comment will be written
        noting that the macro is not supported.

        Handled macros are such macros that code is written to handle them.
        For example for the FootNote macro it means that instead of executing
        the macro, a DocBook footnote entity is created, with the relevant
        pieces of information filles in.

        The Unknown are handled by executing the macro and capturing any
        textual output. There shouldn't be any textual output since macros
        should call formatter methods. This is unfortunately not always true,
        so the output it is then fed in to an xml parser and the
        resulting nodes copied to the DocBook-dom tree. If the output is not
        valid xml then a comment is written in the DocBook that the macro
        should be fixed.

        """
        # Another alternative would be to feed the output to rawHTML or even
        # combining these two approaches. The _best_ alternative would be to
        # fix the macros.
        excludes = (u"articleinfo", u"title")

        if name in self.blacklisted_macros:
            self._emitComment("The macro %s doesn't work with the DocBook formatter." % name)

        elif name == u"FootNote":
            footnote = tree.element(None, u"footnote")
            self._addTextElem(footnote, u"para", str(args))
            self.cur.xml_append(footnote)

        elif name == u"Include":
            was_in_para = self.cur.xml_qname == u"para"
            if was_in_para:
                self.paragraph(0)
            text = FormatterBase.macro(self, macro_obj, name, args)
            if text.strip():
                self._includeExternalDocument(text, exclude=excludes)
            if was_in_para:
                self.paragraph(1)

        else:
            text = FormatterBase.macro(self, macro_obj, name, args)
            if text:
                try:
                    self._includeExternalDocument(text, exclude=excludes)
                # FIXME: check for parse-related errors, realy
                except ExpatError:
                    self._emitComment(
                        u"The macro %s caused an error and should be blacklisted (and you might want to file a bug with the developer). It returned the following data which caused the docbook-formatter to choke. '%s'"
                        % (name, text)
                    )

        return u""
开发者ID:pombredanne,项目名称:akara,代码行数:58,代码来源:text_docbook.py

示例8: __init__

 def __init__(self, request, **kw):
     FormatterBase.__init__(self, request, **kw)
     self._current_depth = 1
     self._base_depth = 0
     self.in_pre = 0
     self._doc = tree.entity()
     self._curr = self._doc
     # self._writer = structwriter(indent=u"yes", encoding=config.charset)
     return
开发者ID:pombredanne,项目名称:akara,代码行数:9,代码来源:application_xml.py

示例9: __init__

 def __init__(self, request, **kw):
     FormatterBase.__init__(self, request, **kw)
     self._in_code_area = 0
     self._in_code_line = 0
     self._code_area_state = [0, -1, -1, 0]
     self._in_list = 0
     self._did_para = 0
     self._url = None
     self._text = None # XXX does not work with links in headings!!!!!
开发者ID:steveyen,项目名称:moingo,代码行数:9,代码来源:text_plain.py

示例10: macro

    def macro(self, macro_obj, name, args, markup=None):
        """As far as the DocBook formatter is conserned there are three
        kinds of macros: Bad, Handled and Unknown.

        The Bad ones are the ones that are known not to work, and are on its
        blacklist. They will be ignored and an XML comment will be written
        noting that the macro is not supported.

        Handled macros are such macros that code is written to handle them.
        For example for the FootNote macro it means that instead of executing
        the macro, a DocBook footnote entity is created, with the relevant
        pieces of information filles in.

        The Unknown are handled by executing the macro and capturing any
        textual output. There shouldn't be any textual output since macros
        should call formatter methods. This is unfortunately not always true,
        so the output it is then fed in to an xml parser and the
        resulting nodes copied to the DocBook-dom tree. If the output is not
        valid xml then a comment is written in the DocBook that the macro
        should be fixed.

        """
        # Another alternative would be to feed the output to rawHTML or even
        # combining these two approaches. The _best_ alternative would be to
        # fix the macros.
        excludes=("articleinfo", "title")

        if name in self.blacklisted_macros:
            self._emitComment("The macro %s doesn't work with the DocBook formatter." % name)

        elif name == "FootNote":
            footnote = self.doc.createElement('footnote')
            self._addTextElem(footnote, "para", str(args))
            self.cur.appendChild(footnote)

        elif name == "Include":
            was_in_para = self.cur.nodeName == "para"
            if was_in_para:
                self.paragraph(0)
            text = FormatterBase.macro(self, macro_obj, name, args)
            if text.strip():
                self._copyExternalNodes(Sax.FromXml(text).documentElement.childNodes, exclude=excludes)
            if was_in_para:
                self.paragraph(1)

        else:
            text = FormatterBase.macro(self, macro_obj, name, args)
            if text:
                from xml.parsers.expat import ExpatError
                try:
                    xml_dom = Sax.FromXml(text).documentElement.childNodes
                    self._copyExternalNodes(xml_dom, exclude=excludes)
                except ExpatError:
                    self._emitComment("The macro %s caused an error and should be blacklisted. It returned the data '%s' which caused the docbook-formatter to choke. Please file a bug." % (name, text))

        return u""
开发者ID:steveyen,项目名称:moingo,代码行数:56,代码来源:text_docbook.py

示例11: _close_tag

 def _close_tag(self, tag):
     """ low level function: closes tag right now
         must be the last opened tag!!!
     """
     if tag == 'p':
         FormatterBase.paragraph(self, 0)
     if self.tag_stack[-1][0] != tag:
         raise ValueError, "closing of <%s> expected, but <%s> closed" % (self.tag_stack[-1][0], tag)
     self.position = self.position.parentNode
     return self.tag_stack.pop()
开发者ID:steveyen,项目名称:moingo,代码行数:10,代码来源:dom_xml.py

示例12: preformatted

 def preformatted(self, on, **kw):
     # Maintain the accessible flag `in_pre`
     FormatterBase.preformatted(self, on)
     if on:
         # TODO Minmized styles should be supported
         result = self._output_EOL_BLK(u"::")
         self._indentation += 3
         return result
     else:
         self._indentation -= 3
         return self._output_EOL_BLK()
开发者ID:ismaelbej,项目名称:moin2rst,代码行数:11,代码来源:text_x-rst.py

示例13: pagelink

    def pagelink(self, on, pagename='', page=None, **kw):
        """ Link to a page.

            formatter.text_python will use an optimized call with a page!=None
            parameter. DO NOT USE THIS YOURSELF OR IT WILL BREAK.

            See wikiutil.link_tag() for possible keyword parameters.
        """
        FormatterBase.pagelink(self, on, pagename, page, **kw)
        if page is None:
            page = Page(self.request, pagename, formatter=self)
        return page.link_to(self.request, on=on, **kw)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:12,代码来源:text_gedit.py

示例14: preformatted

 def preformatted(self, on, **kw):
     FormatterBase.preformatted(self, on)
     snip = u'%s\n' % u'---%<'.ljust(78 - self._indent, u'-')
     if on:
         self.paragraph_begin()
         return self.wrap(snip)
     else:
         if self._textbuf and not self._textbuf.endswith('\n'):
             self._textbuf += '\n'
         result = self.wrap(snip)
         self.paragraph_end()
         return result
开发者ID:IvanLogvinov,项目名称:soar,代码行数:12,代码来源:text_plain.py

示例15: paragraph

    def paragraph(self, on, **kw):
        FormatterBase.paragraph(self, on)

        # Let's prevent empty paras
        if not on:
            if not self._hasContent(self.cur):
                oldnode = self.cur
                self.cur = oldnode.xml_parent
                self.cur.xml_remove(oldnode)
                return ""

        # Let's prevent para inside para
        if on and self.cur.xml_qname == u"para":
            return ""
        return self._handleNode(u"para", on)
开发者ID:pombredanne,项目名称:akara,代码行数:15,代码来源:text_docbook.py


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