[ZPT] CVS: Zope/lib/python/TAL - HTMLParser.py:1.22 markupbase.py:1.2 setpath.py:1.5

Andreas Jung andreas@digicool.com
Fri, 19 Apr 2002 10:16:39 -0400


Update of /cvs-repository/Zope/lib/python/TAL
In directory cvs.zope.org:/tmp/cvs-serv7137/lib/python/TAL

Modified Files:
	HTMLParser.py markupbase.py setpath.py 
Log Message:
replace string module calls by string methods


=== Zope/lib/python/TAL/HTMLParser.py 1.21 => 1.22 ===
 import markupbase
 import re
-import string
 
 # Regular expressions used for parsing
 
@@ -258,7 +257,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)
@@ -271,16 +270,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"
@@ -338,7 +337,7 @@
         if not match:
             self.error("bad end tag: %s" % `rawdata[i:j]`)
         tag = match.group(1)
-        self.handle_endtag(string.lower(tag))
+        self.handle_endtag(tag.lower())
         return j
 
     # Overridable -- finish processing of start+end tag: <tag.../>
@@ -385,9 +384,9 @@
     def unescape(self, s):
         if '&' not in s:
             return s
-        s = string.replace(s, "&lt;", "<")
-        s = string.replace(s, "&gt;", ">")
-        s = string.replace(s, "&apos;", "'")
-        s = string.replace(s, "&quot;", '"')
-        s = string.replace(s, "&amp;", "&") # Must be last
+        s = s.replace("&lt;", "<")
+        s = s.replace("&gt;", ">")
+        s = s.replace("&apos;", "'")
+        s = s.replace("&quot;", '"')
+        s = s.replace("&amp;", "&") # Must be last
         return s


=== Zope/lib/python/TAL/markupbase.py 1.1 => 1.2 ===
 
-import re
-import string
+import re, string
 
 _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match
 _declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match
@@ -29,10 +28,10 @@
         if i >= j:
             return j
         rawdata = self.rawdata
-        nlines = string.count(rawdata, "\n", i, j)
+        nlines = rawdata.count("\n", i, j)
         if nlines:
             self.lineno = self.lineno + nlines
-            pos = string.rindex(rawdata, "\n", i, j) # Should not fail
+            pos = rawdata.rindex("\n", i, j) # Should not fail
             self.offset = j-(pos+1)
         else:
             self.offset = self.offset + j-i
@@ -169,7 +168,7 @@
             return -1
         # style content model; just skip until '>'
         if '>' in rawdata[j:]:
-            return string.find(rawdata, ">", j) + 1
+            return rawdata.find(">", j) + 1
         return -1
 
     # Internal -- scan past <!ATTLIST declarations
@@ -193,7 +192,7 @@
             if c == "(":
                 # an enumerated type; look for ')'
                 if ")" in rawdata[j:]:
-                    j = string.find(rawdata, ")", j) + 1
+                    j = awdata.find(")", j) + 1
                 else:
                     return -1
                 while rawdata[j:j+1] in string.whitespace:
@@ -300,7 +299,7 @@
             name = s.strip()
             if (i + len(s)) == n:
                 return None, -1  # end of buffer
-            return string.lower(name), m.end()
+            return name.lower(), m.end()
         else:
             self.updatepos(declstartpos, i)
             self.error("expected name token", self.getpos())


=== Zope/lib/python/TAL/setpath.py 1.4 => 1.5 ===
         line = line.strip()
         if line and line[0] != '#':
-            for dir in string.split(line, os.pathsep):
+            for dir in line.split(os.pathsep):
                 dir = os.path.expanduser(os.path.expandvars(dir))
                 if dir not in sys.path:
                     sys.path.append(dir)