[Zope-Checkins] CVS: Zope2 - DT_String.py:1.39.52.3

Andreas Jung andreas@dhcp165.digicool.com
Wed, 18 Apr 2001 12:32:57 -0400


Update of /cvs-repository/Zope2/lib/python/DocumentTemplate
In directory yetix:/work/sandboxes/ajung-2_4-ts_regex-exterminiation-branch/lib/python/DocumentTemplate

Modified Files:
      Tag: ajung-2_4-ts_regex-exterminiation-branch
	DT_String.py 
Log Message:
ts_regex/regex free zone
Warning: mostly untested (depends on DT_HTML)



--- Updated File DT_String.py in package Zope2 --
--- DT_String.py	2001/04/18 16:08:15	1.39.52.2
+++ DT_String.py	2001/04/18 16:32:56	1.39.52.3
@@ -85,7 +85,7 @@
 "$Id$"
 
 from string import split, strip
-import thread ,regex,re
+import thread ,re
 
 from DT_Util import ParseError, InstanceDict, TemplateDict, render_blocks, str
 from DT_Var import Var, Call, Comment
@@ -154,15 +154,15 @@
 
     tagre__roles__=()
     def tagre(self):
-        return regex.symcomp(
+        return re.compile(
             '%('                                     # beginning
-            '\(<name>[a-zA-Z0-9_/.-]+\)'                       # tag name
+            '\(?P<name>[a-zA-Z0-9_/.-]+\)'                       # tag name
             '\('
             '[\0- ]+'                                # space after tag name
-            '\(<args>\([^)"]+\("[^"]*"\)?\)*\)'      # arguments
+            '\(?P<args>\([^)"]+\("[^"]*"\)?\)*\)'      # arguments
             '\)?'
-            ')\(<fmt>[0-9]*[.]?[0-9]*[a-z]\|[]![]\)' # end
-            , regex.casefold) 
+            ')\(?P<fmt>[0-9]*[.]?[0-9]*[a-z]\|[]![]\)' # end
+            , re.I) 
 
     _parseTag__roles__=()
     def _parseTag(self, tagre, command=None, sargs='', tt=type(())):
@@ -227,8 +227,9 @@
     def parse(self,text,start=0,result=None,tagre=None):
         if result is None: result=[]
         if tagre is None: tagre=self.tagre()
-        l=tagre.search(text,start)
-        while l >= 0:
+        mo=tagre.search(text,start)
+        while mo is not None:
+            l = mo.start(0)
 
             try: tag, args, command, coname = self._parseTag(tagre)
             except ParseError, m: self.parse_error(m[0],m[1],text,l)
@@ -248,7 +249,7 @@
                     result.append(r)
                 except ParseError, m: self.parse_error(m[0],tag,text,l)
 
-            l=tagre.search(text,start)
+            mo =tagre.search(text,start)
 
         text=text[start:]
         if text: result.append(text)
@@ -278,8 +279,9 @@
         sa=sargs
         while 1:
 
-            l=tagre.search(text,start)
-            if l < 0: self.parse_error('No closing tag', stag, text, sloc)
+            mo =tagre.search(text,start)
+            if mo is None: self.parse_error('No closing tag', stag, text, sloc)
+            l = mo.start(0)
 
             try: tag, args, command, coname= self._parseTag(tagre,scommand,sa)
             except ParseError, m: self.parse_error(m[0],m[1], text, l)
@@ -316,8 +318,9 @@
     parse_close__roles__=()
     def parse_close(self, text, start, tagre, stag, sloc, scommand, sa):
         while 1:
-            l=tagre.search(text,start)
-            if l < 0: self.parse_error('No closing tag', stag, text, sloc)
+            mo =tagre.search(text,start)
+            if mo is None: self.parse_error('No closing tag', stag, text, sloc)
+            l = mo.start(0)
 
             try: tag, args, command, coname= self._parseTag(tagre,scommand,sa)
             except ParseError, m: self.parse_error(m[0],m[1], text, l)