[Zope-Checkins] CVS: Zope2 - Aqueduct.py:1.44.38.2
Andreas Jung
andreas@dhcp165.digicool.com
Mon, 23 Apr 2001 10:39:01 -0400
Update of /cvs-repository/Zope2/lib/python/Shared/DC/ZRDB
In directory yetix:/work/sandboxes/ajung-2_4-ts_regex-exterminiation-branch/lib/python/Shared/DC/ZRDB
Modified Files:
Tag: ajung-2_4-ts_regex-exterminiation-branch
Aqueduct.py
Log Message:
regex/ts_regex free
--- Updated File Aqueduct.py in package Zope2 --
--- Aqueduct.py 2001/04/19 22:45:13 1.44.38.1
+++ Aqueduct.py 2001/04/23 14:37:59 1.44.38.2
@@ -89,7 +89,7 @@
import Globals, os
from Globals import Persistent
-import DocumentTemplate, DateTime, ts_regex, re, string
+import DocumentTemplate, DateTime, re, string
import binascii, Acquisition
DateTime.now=DateTime.DateTime
from cStringIO import StringIO
@@ -343,12 +343,12 @@
def parse(text,
result=None,
keys=None,
- unparmre=ts_regex.compile(
- '\([\0- ]*\([^\0- =\"]+\)\)'),
- parmre=ts_regex.compile(
- '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'),
- qparmre=ts_regex.compile(
- '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'),
+ unparmre=re.compile(
+ r'([\0- ]*([^\0- =\"]+))'),
+ parmre=re.compile(
+ r'([\0- ]*([^\0- =\"]+)=([^\0- =\"]+))'),
+ qparmre=re.compile(
+ r'([\0- ]*([^\0- =\"]+)="([^"]*)\")'),
):
if result is None:
@@ -357,25 +357,22 @@
__traceback_info__=text
- ts_results = parmre.match_group(text, (1,2,3))
- if ts_results:
- start, grps = ts_results
- name=grps[1]
- value={'default':grps[2]}
- l=len(grps[0])
+ mo = parmre.match(text)
+ if mo:
+ name=mo.group(1)
+ value={'default':mo.group(2)}
+ l=len(mo.group(0))
else:
- ts_results = qparmre.match_group(text, (1,2,3))
- if ts_results:
- start, grps = ts_results
- name=grps[1]
- value={'default':grps[2]}
- l=len(grps[0])
+ mo = qparmre.match(text)
+ if mo:
+ name=mo.group(0)
+ value={'default':mo.group(2)}
+ l=len(mo.group(0))
else:
- ts_results = unparmre.match_group(text, (1,2))
+ mo = unparmre.match(text)
if ts_results:
- start, grps = ts_results
- name=grps[1]
- l=len(grps[0])
+ name=mo.group(1)
+ l=len(mo.group(0))
value={}
else:
if not text or not strip(text): return Args(result,keys)
@@ -410,22 +407,22 @@
return string.upper(name[:1])+name[1:]
def decapitate(html, RESPONSE=None,
- header_re=ts_regex.compile(
- '\(\('
+ header_re=re.compile(
+ r'(('
'[^\0- <>:]+:[^\n]*\n'
'\|'
'[ \t]+[^\0- ][^\n]*\n'
- '\)+\)[ \t]*\n\([\0-\377]+\)'
+ ')+)[ \t]*\n([\0-\377]+)'
),
- space_re=ts_regex.compile('\([ \t]+\)'),
- name_re=ts_regex.compile('\([^\0- <>:]+\):\([^\n]*\)'),
+ space_re=re.compile(r'([ \t]+)'),
+ name_re=re.compile(r'([^\0- <>:]+):([^\n]*)'),
):
- ts_results = header_re.match_group(html, (1,3))
- if not ts_results: return html
+ mo = header_re.match(html)
+ if mo is None: return html
- headers, html = ts_results[1]
+ headers, html = mo.group(1,3)
headers=string.split(headers,'\n')
@@ -434,18 +431,18 @@
if not headers[i]:
del headers[i]
else:
- ts_results = space_re.match_group(headers[i], (1,))
- if ts_results:
+ mo = space_re.match(headers[i])
+ if mo:
headers[i-1]="%s %s" % (headers[i-1],
- headers[i][len(ts_reults[1]):])
+ headers[i][len(mo.group(1)):])
del headers[i]
else:
i=i+1
for i in range(len(headers)):
- ts_results = name_re.match_group(headers[i], (1,2))
- if ts_reults:
- k, v = ts_reults[1]
+ mo = name_re.match(headers[i])
+ if mo:
+ k,v = mo.group(1,2)
v=string.strip(v)
else:
raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i])