Commit 13b51ae7 authored by Shane Hathaway's avatar Shane Hathaway

Fixed some re's

parent 30a9be8a
......@@ -84,7 +84,7 @@
##############################################################################
"""HTML formated DocumentTemplates
$Id: DT_HTML.py,v 1.26 2001/04/28 04:59:13 chrism Exp $"""
$Id: DT_HTML.py,v 1.27 2001/04/30 14:46:00 shane Exp $"""
from DT_String import String, FileMixin
import DT_String, re
......@@ -94,10 +94,10 @@ from string import strip, find, split, join, rfind, replace
class dtml_re_class:
""" This needs to be replaced before 2.4. It's a hackaround. """
def search(self, text, start=0,
name_match=re.compile(r'[\000- ]*[a-zA-Z]+[\000- ]*').match,
end_match=re.compile(r'[\000- ]*(/|end)', re.I).match,
start_search=re.compile(r'[<&]').search,
ent_name=re.compile(r'[-a-zA-Z0-9_.]+').match,
name_match=re.compile('[\000- ]*[a-zA-Z]+[\000- ]*').match,
end_match=re.compile('[\000- ]*(/|end)', re.I).match,
start_search=re.compile('[<&]').search,
ent_name=re.compile('[-a-zA-Z0-9_.]+').match,
find=find,
strip=strip,
replace=replace,
......@@ -224,7 +224,7 @@ class HTML(DT_String.String):
return dtml_re_class()
parseTag__roles__=()
def parseTag(self, tagre, command=None, sargs=''):
def parseTag(self, match_ob, command=None, sargs=''):
"""Parse a tag using an already matched re
Return: tag, args, command, coname
......@@ -236,7 +236,7 @@ class HTML(DT_String.String):
coname is the name of a continue tag (e.g. else)
or None otherwise
"""
tag, end, name, args, =tagre.group(0, 'end', 'name', 'args')
tag, end, name, args = match_ob.group(0, 'end', 'name', 'args')
args=strip(args)
if end:
if not command or name != command.name:
......@@ -263,7 +263,7 @@ class HTML(DT_String.String):
def SubTemplate(self, name): return HTML('', __name__=name)
varExtra__roles__=()
def varExtra(self,tagre): return 's'
def varExtra(self, match_ob): return 's'
manage_edit__roles__=()
def manage_edit(self,data,REQUEST=None):
......
......@@ -154,8 +154,8 @@ class Let:
def parse_let_params(text,
result=None,
tag='let',
parmre=re.compile(r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
qparmre=re.compile(r'([\000- ]*([^\000- ="]+)="([^"]*)")'),
parmre=re.compile('([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
qparmre=re.compile('([\000- ]*([^\000- ="]+)="([^"]*)")'),
**parms):
result=result or []
......
......@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
"$Id: DT_String.py,v 1.43 2001/04/28 07:20:28 chrism Exp $"
"$Id: DT_String.py,v 1.44 2001/04/30 14:46:00 shane Exp $"
from string import split, strip
import thread,re
......@@ -155,18 +155,18 @@ class String:
tagre__roles__=()
def tagre(self):
return re.compile(
r'%(' # beginning
r'(?P<name>[a-zA-Z0-9_/.-]+)' # tag name
r'('
r'[\000- ]+' # space after tag name
r'(?P<args>([^)"]+("[^"]*")?)*)' # arguments
r')?'
r')(?P<fmt>[0-9]*[.]?[0-9]*[a-z]|[]![])' # end
, re.I)
'%\\(' # beginning
'(?P<name>[a-zA-Z0-9_/.-]+)' # tag name
'('
'[\000- ]+' # space after tag name
'(?P<args>([^\\)"]+("[^"]*")?)*)' # arguments
')?'
'\\)(?P<fmt>[0-9]*[.]?[0-9]*[a-z]|[]![])' # end
, re.I)
_parseTag__roles__=()
def _parseTag(self, tagre, command=None, sargs='', tt=type(())):
tag, args, command, coname = self.parseTag(tagre,command,sargs)
def _parseTag(self, match_ob, command=None, sargs='', tt=type(())):
tag, args, command, coname = self.parseTag(match_ob,command,sargs)
if type(command) is tt:
cname, module, name = command
d={}
......@@ -179,7 +179,7 @@ class String:
return tag, args, command, coname
parseTag__roles__=()
def parseTag(self, tagre, command=None, sargs=''):
def parseTag(self, match_ob, command=None, sargs=''):
"""Parse a tag using an already matched re
Return: tag, args, command, coname
......@@ -191,7 +191,7 @@ class String:
coname is the name of a continue tag (e.g. else)
or None otherwise
"""
tag, name, args, fmt =tagre.group(0, 'name', 'args', 'fmt')
tag, name, args, fmt = match_ob.group(0, 'name', 'args', 'fmt')
args=args and strip(args) or ''
if fmt==']':
......@@ -220,18 +220,18 @@ class String:
return tag, args, Var, None
varExtra__roles__=()
def varExtra(self,tagre):
return tagre.group('fmt')
def varExtra(self, match_ob):
return match_ob.group('fmt')
parse__roles__=()
def parse(self,text,start=0,result=None,tagre=None):
if result is None: result=[]
if tagre is None: tagre=self.tagre()
mo =tagre.search(text,start)
mo = tagre.search(text,start)
while mo :
l = mo.start(0)
try: tag, args, command, coname = self._parseTag(tagre)
try: tag, args, command, coname = self._parseTag(mo)
except ParseError, m: self.parse_error(m[0],m[1],text,l)
s=text[start:l]
......@@ -243,7 +243,7 @@ class String:
tag, l, args, command)
else:
try:
if command is Var: r=command(args, self.varExtra(tagre))
if command is Var: r=command(args, self.varExtra(mo))
else: r=command(args)
if hasattr(r,'simple_form'): r=r.simple_form
result.append(r)
......@@ -256,7 +256,7 @@ class String:
return result
skip_eol__roles__=()
def skip_eol(self, text, start, eol=re.compile(r'[ \t]*\n')):
def skip_eol(self, text, start, eol=re.compile('[ \t]*\n')):
# if block open is followed by newline, then skip past newline
mo =eol.match(text,start)
if mo is not None:
......@@ -281,7 +281,7 @@ class String:
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)
try: tag, args, command, coname= self._parseTag(mo,scommand,sa)
except ParseError, m: self.parse_error(m[0],m[1], text, l)
if command:
......@@ -320,7 +320,7 @@ class String:
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)
try: tag, args, command, coname= self._parseTag(mo,scommand,sa)
except ParseError, m: self.parse_error(m[0],m[1], text, l)
start=l+len(tag)
......
......@@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
'''$Id: DT_Util.py,v 1.75 2001/04/28 04:58:53 chrism Exp $'''
__version__='$Revision: 1.75 $'[11:-2]
'''$Id: DT_Util.py,v 1.76 2001/04/30 14:46:00 shane Exp $'''
__version__='$Revision: 1.76 $'[11:-2]
import re, os
from string import lower
......@@ -339,14 +339,10 @@ ListType=type([])
def parse_params(text,
result=None,
tag='',
unparmre=re.compile(
r'([\000- ]*([^\000- ="]+))'),
qunparmre=re.compile(
r'([\000- ]*("[^"]*"))'),
parmre=re.compile(
r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
qparmre=re.compile(
r'([\000- ]*([^\000- ="]+)="([^"]*)")'),
unparmre=re.compile('([\000- ]*([^\000- ="]+))'),
qunparmre=re.compile('([\000- ]*("[^"]*"))'),
parmre=re.compile('([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
qparmre=re.compile('([\000- ]*([^\000- ="]+)="([^"]*)")'),
**parms):
"""Parse tag parameters
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment