[Zope-Checkins] CVS: Zope2 - Converters.py:1.11

Andreas Jung andreas@dhcp165.digicool.com
Tue, 24 Apr 2001 16:38:52 -0400


Update of /cvs-repository/Zope2/lib/python/ZPublisher
In directory yetix:/work/sandboxes/Zope2/lib/python/ZPublisher

Modified Files:
	Converters.py 
Log Message:
regex free (tested)



--- Updated File Converters.py in package Zope2 --
--- Converters.py	2001/01/23 16:48:02	1.10
+++ Converters.py	2001/04/24 20:38:46	1.11
@@ -84,7 +84,7 @@
 ##############################################################################
 __version__='$Revision$'[11:-2]
 
-import regex
+import re
 from string import atoi, atol, atof, join, split, strip
 from types import ListType, TupleType
 
@@ -93,17 +93,21 @@
     else: v=str(v)
     return v
 
-def field2text(v, nl=regex.compile('\r\n\|\n\r').search):
+def field2text(v, nl=re.compile('\r\n\|\n\r').search):
     if hasattr(v,'read'): v=v.read()
     else: v=str(v)
-    l=nl(v)
-    if l < 0: return v
+    mo = nl(v)
+    if mo is None: return v
+    l = mo.start(0)
     r=[]
     s=0
     while l >= s:
         r.append(v[s:l])
         s=l+2
-        l=nl(v,s)
+        mo=nl(v,s)
+        if mo is None: l=-1
+        else:          l=mo.start(0)
+
     r.append(v[s:])
         
     return join(r,'\n')