changeset 5254:fc47ff90b96f

parser: move parse_start_stop to package init so that ParserBase deprecation warning is not accidentally triggered
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 07 Nov 2009 04:52:08 +0100
parents 4155de7a48ca
children ec00e39ec3f8
files MoinMoin/parser/_ParserBase.py MoinMoin/parser/__init__.py MoinMoin/parser/highlight.py
diffstat 3 files changed, 40 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/_ParserBase.py	Sat Nov 07 03:29:10 2009 +0100
+++ b/MoinMoin/parser/_ParserBase.py	Sat Nov 07 04:52:08 2009 +0100
@@ -31,6 +31,8 @@
 
 from MoinMoin import config, wikiutil
 from MoinMoin.support.python_compatibility import hash_new
+from MoinMoin.parser import parse_start_step
+
 
 class FormatTextBase:
     pass
@@ -116,44 +118,6 @@
         return hit + r
 
 
-# ------------------------------------------------------------------------
-
-def parse_start_step(request, args):
-    """
-    Parses common Colorizer parameters start, step, numbers.
-    Uses L{wikiutil.parseAttributes} and sanitizes the results.
-
-    Start and step must be a non negative number and default to 1,
-    numbers might be on, off, or none and defaults to on. On or off
-    means that numbers are switchable via JavaScript (html formatter),
-    disabled means that numbers are disabled completely.
-
-    attrdict is returned as last element in the tuple, to enable the
-    calling parser to extract further arguments.
-
-    @param request: a request instance
-    @param args: the argument string
-
-    @returns: numbers, start, step, attrdict
-    """
-    nums, start, step = 1, 1, 1
-    attrs, msg = wikiutil.parseAttributes(request, args)
-    if not msg:
-        try:
-            start = int(attrs.get('start', '"1"')[1:-1])
-        except ValueError:
-            pass
-        try:
-            step = int(attrs.get('step', '"1"')[1:-1])
-        except ValueError:
-            pass
-        if attrs.get('numbers', '"on"')[1:-1].lower() in ('off', 'false', 'no'):
-            nums = 0
-        elif attrs.get('numbers', '"on"')[1:-1].lower() in ('none', 'disable'):
-            nums = -1
-    return nums, start, step, attrs
-
-
 class ParserBase:
     """ DEPRECATED highlighting parser - please use/extend pygments library """
     logging.warning('Using ParserBase is deprecated - please use/extend pygments syntax highlighting library.')
--- a/MoinMoin/parser/__init__.py	Sat Nov 07 03:29:10 2009 +0100
+++ b/MoinMoin/parser/__init__.py	Sat Nov 07 04:52:08 2009 +0100
@@ -10,6 +10,43 @@
 """
 
 from MoinMoin.util import pysupport
+from MoinMoin import wikiutil
 
 modules = pysupport.getPackageModules(__file__)
 
+
+def parse_start_step(request, args):
+    """
+    Parses common Colorizer parameters start, step, numbers.
+    Uses L{wikiutil.parseAttributes} and sanitizes the results.
+
+    Start and step must be a non negative number and default to 1,
+    numbers might be on, off, or none and defaults to on. On or off
+    means that numbers are switchable via JavaScript (html formatter),
+    disabled means that numbers are disabled completely.
+
+    attrdict is returned as last element in the tuple, to enable the
+    calling parser to extract further arguments.
+
+    @param request: a request instance
+    @param args: the argument string
+
+    @returns: numbers, start, step, attrdict
+    """
+    nums, start, step = 1, 1, 1
+    attrs, msg = wikiutil.parseAttributes(request, args)
+    if not msg:
+        try:
+            start = int(attrs.get('start', '"1"')[1:-1])
+        except ValueError:
+            pass
+        try:
+            step = int(attrs.get('step', '"1"')[1:-1])
+        except ValueError:
+            pass
+        if attrs.get('numbers', '"on"')[1:-1].lower() in ('off', 'false', 'no'):
+            nums = 0
+        elif attrs.get('numbers', '"on"')[1:-1].lower() in ('none', 'disable'):
+            nums = -1
+    return nums, start, step, attrs
+
--- a/MoinMoin/parser/highlight.py	Sat Nov 07 03:29:10 2009 +0100
+++ b/MoinMoin/parser/highlight.py	Sat Nov 07 04:52:08 2009 +0100
@@ -15,7 +15,7 @@
 from pygments.token import Token
 
 from MoinMoin import config
-from MoinMoin.parser._ParserBase import parse_start_step
+from MoinMoin.parser import parse_start_step
 from MoinMoin.support.python_compatibility import hash_new
 
 Dependencies = []