Mercurial > p > roundup > code
diff roundup/cgi/TAL/HTMLParser.py @ 2348:8c2402a78bb0
beginning getting ZPT up to date: TAL first
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 21 May 2004 05:36:30 +0000 |
| parents | fc52d57c6c3e |
| children | 63868084b8bb |
line wrap: on
line diff
--- a/roundup/cgi/TAL/HTMLParser.py Thu May 20 23:16:58 2004 +0000 +++ b/roundup/cgi/TAL/HTMLParser.py Fri May 21 05:36:30 2004 +0000 @@ -1,5 +1,4 @@ """A parser for HTML and XHTML.""" -__docformat__ = 'restructuredtext' # This file is based on sgmllib.py, but the API is slightly different. @@ -11,7 +10,6 @@ import markupbase import re -import string # Regular expressions used for parsing @@ -261,7 +259,7 @@ match = tagfind.match(rawdata, i+1) assert match, 'unexpected call to parse_starttag()' k = match.end() - self.lasttag = tag = string.lower(rawdata[i+1:k]) + self.lasttag = tag = rawdata[i+1:k].lower() while k < endpos: m = attrfind.match(rawdata, k) @@ -274,16 +272,16 @@ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrvalue = self.unescape(attrvalue) - attrs.append((string.lower(attrname), attrvalue)) + attrs.append((attrname.lower(), attrvalue)) k = m.end() - end = string.strip(rawdata[k:endpos]) + end = rawdata[k:endpos].strip() if end not in (">", "/>"): lineno, offset = self.getpos() if "\n" in self.__starttag_text: - lineno = lineno + string.count(self.__starttag_text, "\n") + lineno = lineno + self.__starttag_text.count("\n") offset = len(self.__starttag_text) \ - - string.rfind(self.__starttag_text, "\n") + - self.__starttag_text.rfind("\n") else: offset = offset + len(self.__starttag_text) self.error("junk characters in start tag: %s" @@ -340,7 +338,7 @@ match = endtagfind.match(rawdata, i) # </ + tag + > if not match: self.error("bad end tag: %s" % `rawdata[i:j]`) - tag = string.lower(match.group(1)) + tag = match.group(1).lower() if ( self.cdata_endtag is not None and tag != self.cdata_endtag): # Should be a mismatched end tag, but we'll treat it @@ -396,9 +394,9 @@ def unescape(self, s): if '&' not in s: return s - s = string.replace(s, "<", "<") - s = string.replace(s, ">", ">") - s = string.replace(s, "'", "'") - s = string.replace(s, """, '"') - s = string.replace(s, "&", "&") # Must be last + s = s.replace("<", "<") + s = s.replace(">", ">") + s = s.replace("'", "'") + s = s.replace(""", '"') + s = s.replace("&", "&") # Must be last return s
