changeset 639:a80a6c629bc3

remove processor support, use a parser now
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 12 May 2006 21:10:11 +0200
parents 1741e021aa17
children 80d0ad85a2d8
files MoinMoin/formatter/base.py MoinMoin/formatter/dom_xml.py MoinMoin/formatter/text_gedit.py MoinMoin/formatter/text_python.py MoinMoin/macro/SystemInfo.py MoinMoin/parser/CSV.py MoinMoin/parser/wiki.py MoinMoin/processor/.cvsignore MoinMoin/processor/__init__.py MoinMoin/util/wikiext.py MoinMoin/wikiutil.py docs/CHANGES wiki/data/plugin/processor/.cvsignore wiki/data/plugin/processor/__init__.py
diffstat 14 files changed, 61 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/formatter/base.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/formatter/base.py	Fri May 12 21:10:11 2006 +0200
@@ -299,23 +299,17 @@
                 return args
         return None
 
-    def processor(self, processor_name, lines, is_parser=0):
-        """ processor_name MUST be valid!
+    def parser(self, parser_name, lines):
+        """ parser_name MUST be valid!
             writes out the result instead of returning it!
         """
-        if not is_parser:
-            processor = wikiutil.importPlugin(self.request.cfg, "processor",
-                                              processor_name, "process")
-            processor(self.request, self, lines)
-        else:
-            parser = wikiutil.importPlugin(self.request.cfg, "parser",
-                                           processor_name, "Parser")
-            args = self._get_bang_args(lines[0])
-            if args is not None:
-                lines = lines[1:]
-            p = parser('\n'.join(lines), self.request, format_args=args)
-            p.format(self)
-            del p
+        parser = wikiutil.importPlugin(self.request.cfg, "parser", parser_name, "Parser")
+        args = self._get_bang_args(lines[0])
+        if args is not None:
+            lines = lines[1:]
+        p = parser('\n'.join(lines), self.request, format_args=args)
+        p.format(self)
+        del p
         return ''
 
     def dynamic_content(self, parser, callback, arg_list=[], arg_dict={},
--- a/MoinMoin/formatter/dom_xml.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/formatter/dom_xml.py	Fri May 12 21:10:11 2006 +0200
@@ -206,17 +206,16 @@
         # call the macro
         return self._add_tag('macro', name=name, args=(args or ''))
 
-    def processor(self, processor_name, lines, is_parser=0):
-        """ processor_name MUST be valid!
+    def parser(self, parser_name, lines):
+        """ parser_name MUST be valid!
             writes out the result instead of returning it!
         """
-        node = self.document.createElement('processor')
-        node.setAttribute('name', processor_name)
-        node.setAttribute('isparser', is_parser)
+        node = self.document.createElement('parser')
+        node.setAttribute('name', parser_name)
         node.appendChild(self.document.createTextNode('\n'.join(lines)))
-        return (self._set_tag('processor', True, name=processor_name, isparser=is_parser) +
+        return (self._set_tag('parser', True, name=parser_name) +
                 self.text('\n'.join(lines)) +
-                self._set_tag('processor', False))
+                self._set_tag('parser', False))
 
     def dynamic_content(self, parser, callback, arg_list=[], arg_dict={}, returns_content=1):
         content = parser[callback](*arg_list, **arg_dict)
--- a/MoinMoin/formatter/text_gedit.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/formatter/text_gedit.py	Fri May 12 21:10:11 2006 +0200
@@ -100,8 +100,8 @@
             result = "[[%s]]" % name
         return '<span style="background-color:#ffff11">%s</span>' % result
 
-    def processor(self, processor_name, lines, is_parser=0):
-        """ processor_name MUST be valid!
+    def parser(self, parser_name, lines):
+        """ parser_name MUST be valid!
         """
         result = [self.preformatted(1)]
         for line in lines:
--- a/MoinMoin/formatter/text_python.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/formatter/text_python.py	Fri May 12 21:10:11 2006 +0200
@@ -180,22 +180,19 @@
                 (self.__adjust_formatter_state(),
                  self.__formatter, name, args))
             
-    def processor(self, processor_name, lines, is_parser=0):
-        """ processor_name MUST be valid!
-        prints out the result insted of returning it!
+    def parser(self, parser_name, lines):
+        """ parser_name MUST be valid!
+            prints out the result instead of returning it!
         """
-        type = ["processor", "parser"][is_parser]
         try:
-            Dependencies = wikiutil.importPlugin(self.request.cfg, type,
-                                                 processor_name,
-                                                 "Dependencies")
+            Dependencies = wikiutil.importPlugin(self.request.cfg, "parser", parser_name, "Dependencies")
         except wikiutil.PluginAttributeError:
             Dependencies = self.defaultDependencies
         if self.__is_static(Dependencies):
-            return self.formatter.processor(processor_name, lines, is_parser)
+            return self.formatter.parser(parser_name, lines)
         else:
-            return self.__insert_code('%s%s.processor(%r, %r, %r)' %
+            return self.__insert_code('%s%s.parser(%r, %r)' %
                                       (self.__adjust_formatter_state(),
                                        self.__formatter,
-                                       processor_name, lines, is_parser))
+                                       parser_name, lines))
 
--- a/MoinMoin/macro/SystemInfo.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/macro/SystemInfo.py	Fri May 12 21:10:11 2006 +0200
@@ -14,7 +14,7 @@
 from StringIO import StringIO
 
 from MoinMoin import wikiutil, version
-from MoinMoin import action, macro, parser, processor
+from MoinMoin import action, macro, parser
 from MoinMoin.logfile import editlog, eventlog
 from MoinMoin.Page import Page
 
@@ -110,8 +110,6 @@
     row(_('Global parsers'), ', '.join(parser.modules) or nonestr)
     row(_('Local extension parsers'), 
         ', '.join(wikiutil.wikiPlugins('parser', Macro.cfg)) or nonestr)
-    row(_('Installed processors (DEPRECATED -- use Parsers instead)'), 
-        ', '.join(processor.processors) or nonestr)
     
     state = (_('Disabled'), _('Enabled'))
     row(_('Lupy search'), state[request.cfg.lupy_search])
--- a/MoinMoin/parser/CSV.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/parser/CSV.py	Fri May 12 21:10:11 2006 +0200
@@ -2,9 +2,7 @@
 """
     MoinMoin - Parser for CSV data
 
-    This is just a copy of the old CSV processor.
-    I think it is intended as an example, cause it
-    lacks to flexibility to read arbitary csv dialects.
+    This parser lacks to flexibility to read arbitary csv dialects.
 
     Perhaps this should be rewritten using another CSV lib
     because the standard module csv does not support unicode.
--- a/MoinMoin/parser/wiki.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/parser/wiki.py	Fri May 12 21:10:11 2006 +0200
@@ -62,7 +62,7 @@
 (?P<sup>\^.*?\^)
 (?P<sub>,,[^,]{1,40},,)
 (?P<tt>\{\{\{.*?\}\}\})
-(?P<processor>(\{\{\{(#!.*|\s*$)))
+(?P<parser>(\{\{\{(#!.*|\s*$)))
 (?P<pre>(\{\{\{ ?|\}\}\}))
 (?P<small>(\~- ?|-\~))
 (?P<big>(\~\+ ?|\+\~))
@@ -101,7 +101,7 @@
     # Don't start p before these 
     no_new_p_before = ("heading rule table tableZ tr td "
                        "ul ol dl dt dd li li_none indent "
-                       "macro processor pre")
+                       "macro parser pre")
     no_new_p_before = no_new_p_before.split()
     no_new_p_before = dict(zip(no_new_p_before, [1] * len(no_new_p_before)))
 
@@ -767,14 +767,13 @@
         return (result + self.formatter.text(title_text) +
                 self.formatter.heading(0, depth))
     
-    def _processor_repl(self, word):
-        """Handle processed code displays."""
+    def _parser_repl(self, word):
+        """Handle parsed code displays."""
         if word[:3] == '{{{':
             word = word[3:]
 
-        self.processor = None
-        self.processor_name = None
-        self.processor_is_parser = 0
+        self.parser = None
+        self.parser_name = None
         s_word = word.strip()
         if s_word == '#!':
             # empty bang paths lead to a normal code display
@@ -783,14 +782,14 @@
             self.in_pre = 3
             return self._closeP() + self.formatter.preformatted(1)
         elif s_word[:2] == '#!':
-            # First try to find a processor for this (will go away in 2.0)
-            processor_name = s_word[2:].split()[0]
-            self.setProcessor(processor_name)
+            # First try to find a parser for this (will go away in 2.0)
+            parser_name = s_word[2:].split()[0]
+            self.setParser(parser_name)
 
-        if self.processor:
-            self.processor_name = processor_name
+        if self.parser:
+            self.parser_name = parser_name
             self.in_pre = 2
-            self.colorize_lines = [word]
+            self.parser_lines = [word]
             return ''
         elif s_word:
             self.in_pre = 3
@@ -982,17 +981,16 @@
                 # still looking for processing instructions
                 # TODO: use strings for pre state, not numbers
                 if self.in_pre == 1:
-                    self.processor = None
-                    self.processor_is_parser = 0
-                    processor_name = ''
+                    self.parser = None
+                    parser_name = ''
                     if (line.strip()[:2] == "#!"):
-                        processor_name = line.strip()[2:].split()[0]
-                        self.setProcessor(processor_name)
+                        parser_name = line.strip()[2:].split()[0]
+                        self.setParser(parser_name)
 
-                    if self.processor:
+                    if self.parser:
                         self.in_pre = 2
-                        self.colorize_lines = [line]
-                        self.processor_name = processor_name
+                        self.parser_lines = [line]
+                        self.parser_name = parser_name
                         continue
                     else:
                         self.request.write(self._closeP() +
@@ -1002,21 +1000,19 @@
                     # processing mode
                     endpos = line.find("}}}")
                     if endpos == -1:
-                        self.colorize_lines.append(line)
+                        self.parser_lines.append(line)
                         continue
                     if line[:endpos]:
-                        self.colorize_lines.append(line[:endpos])
+                        self.parser_lines.append(line[:endpos])
                     
-                    # Close p before calling processor
+                    # Close p before calling parser
                     # TODO: do we really need this?
                     self.request.write(self._closeP())
-                    res = self.formatter.processor(self.processor_name,
-                                                   self.colorize_lines, 
-                                                   self.processor_is_parser)
+                    res = self.formatter.parser(self.parser_name, self.parser_lines)
                     self.request.write(res)
-                    del self.colorize_lines
+                    del self.parser_lines
                     self.in_pre = 0
-                    self.processor = None
+                    self.parser = None
 
                     # send rest of line through regex machinery
                     line = line[endpos+3:]
@@ -1109,22 +1105,13 @@
         if self.formatter.in_p: self.request.write(self.formatter.paragraph(0))
         if self.in_table: self.request.write(self.formatter.table(0))
 
-    # --------------------------------------------------------------------
-    # Private helpers
+    # Private helpers ------------------------------------------------------------
     
-    def setProcessor(self, name):
-        """ Set processer to either processor or parser named 'name' """
-        cfg = self.request.cfg
+    def setParser(self, name):
+        """ Set parser to parser named 'name' """
         try:
-            self.processor = wikiutil.importPlugin(cfg, "processor", name,
-                                                   "process")
-            self.processor_is_parser = 0
+            self.parser = wikiutil.importPlugin(self.request.cfg, "parser", name, "Parser")
         except wikiutil.PluginMissingError:
-            try:
-                self.processor = wikiutil.importPlugin(cfg, "parser", name,
-                                                   "Parser")
-                self.processor_is_parser = 1
-            except wikiutil.PluginMissingError:
-                self.processor = None
+            self.parser = None
 
 
--- a/MoinMoin/processor/.cvsignore	Fri May 12 20:34:21 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-*.pyo
-*.pyc
-{arch}
-.arch-ids
--- a/MoinMoin/processor/__init__.py	Fri May 12 20:34:21 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Processor Package
-
-    DEPRECATED!
-
-    Please use Parsers instead of Processors.
-
-    @copyright: 2002 by Jürgen Hermann <jh@web.de>
-    @license: GNU GPL, see COPYING for details.
-"""
-
-from MoinMoin.util import pysupport
-
-processors = pysupport.getPackageModules(__file__)
-modules = processors
--- a/MoinMoin/util/wikiext.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/util/wikiext.py	Fri May 12 21:10:11 2006 +0200
@@ -4,7 +4,7 @@
 
     The stuff in this module is especially geared towards
     writing extensions / plugins, i.e. additional actions,
-    macros, processors, parsers and formatters.
+    macros, parsers and formatters.
 
     See MoinMoin.wikiutil for more.
 
--- a/MoinMoin/wikiutil.py	Fri May 12 20:34:21 2006 +0200
+++ b/MoinMoin/wikiutil.py	Fri May 12 21:10:11 2006 +0200
@@ -782,9 +782,8 @@
     imported, raise PluginMissingError. If function is missing, raise
     PluginAttributeError.
 
-    kind may be one of 'action', 'formatter', 'macro', 'processor',
-    'parser' or any other directory that exist in MoinMoin or
-    data/plugin
+    kind may be one of 'action', 'formatter', 'macro', 'parser' or any other
+    directory that exist in MoinMoin or data/plugin.
 
     Wiki plugins will always override builtin plugins. If you want
     specific plugin, use either importWikiPlugin or importBuiltinPlugin
--- a/docs/CHANGES	Fri May 12 20:34:21 2006 +0200
+++ b/docs/CHANGES	Fri May 12 21:10:11 2006 +0200
@@ -42,7 +42,8 @@
     * moved wikimacro.py stuff to MoinMoin/macro/__init__.py
     * moved wikirpc.py stuff to MoinMoin/xmlrpc/__init__.py
     * moved wikitest.py stuff to action/test.py (only used from there)
-
+    * killed "processors" (finally), formatter method changed to:
+      formatter.parser(parsername, lines)
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page
--- a/wiki/data/plugin/processor/.cvsignore	Fri May 12 20:34:21 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-*.pyc
-*.pyo
-{arch}
-.arch-ids
-
--- a/wiki/data/plugin/processor/__init__.py	Fri May 12 20:34:21 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-
-from MoinMoin.util import pysupport
-
-modules = pysupport.getPackageModules(__file__)