[ZPT] CVS: Zope/lib/python/ZTUtils - Iterator.py:1.6 Tree.py:1.5 Zope.py:1.9

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


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

Modified Files:
	Iterator.py Tree.py Zope.py 
Log Message:
replace string module calls by string methods


=== Zope/lib/python/ZTUtils/Iterator.py 1.5 => 1.6 ===
 __version__='$Revision$'[11:-2]
 
-import string
-
 class Iterator:
     '''Simple Iterator class'''
 
@@ -88,8 +86,8 @@
             s = s + r * rct
         return s
 
-    def roman(self, lower=string.lower):
-        return lower(self.Roman())
+    def roman(self):
+        return self.Roman().lower()
 
     def first(self, name=None):
         if self.start: return 1


=== Zope/lib/python/ZTUtils/Tree.py 1.4 => 1.5 ===
 
 from binascii import b2a_base64, a2b_base64
-import string
-from string import split, join, translate
+from string import translate, maketrans
 
-a2u_map = string.maketrans('+/=', '-._')
-u2a_map = string.maketrans('-._', '+/=')
+a2u_map = maketrans('+/=', '-._')
+u2a_map = maketrans('-._', '+/=')
 
 def b2a(s):
     '''Encode a value as a cookie- and url-safe string.
@@ -164,7 +163,7 @@
     frags = []
     for i in range(0, len(s), 57):
         frags.append(b2a_base64(s[i:i + 57])[:-1])
-    return translate(join(frags, ''), a2u_map)
+    return translate(''.join(frags), a2u_map)
 
 def a2b(s):
     '''Decode a b2a-encoded string.'''
@@ -174,7 +173,7 @@
     frags = []
     for i in range(0, len(s), 76):
         frags.append(a2b_base64(s[i:i + 76]))
-    return join(frags, '')
+    return ''.join(frags)
 
 def encodeExpansion(nodes):
     '''Encode the expanded node ids of a tree into a string.
@@ -196,7 +195,7 @@
         steps.append(node.id)
         node.expansion_number = n
         n = n + 1
-    return join(steps, ':')
+    return ':'.join(steps)
         
 def decodeExpansion(s, nth=None):
     '''Decode an expanded node map from a string.
@@ -209,7 +208,7 @@
     nth_pair = None
     if nth is not None:
         nth_pair = (None, None)
-    for step in split(s, ':'):
+    for step in s.split(':'):
         if step[:1] == '.':
             pop = len(step) - 1
             continue


=== Zope/lib/python/ZTUtils/Zope.py 1.8 => 1.9 ===
 from Products.ZCatalog.Lazy import Lazy
 from AccessControl import getSecurityManager
-from string import split, join
 from types import StringType, ListType, IntType, FloatType
 from DateTime import DateTime
 
@@ -117,7 +116,7 @@
         if state:
             setst = req.form.get(set_name)
             if setst:
-                st, pn, expid = split(setst, ',')
+                st, pn, expid = setst.split(',')
                 state, (m, obid) = decodeExpansion(state, int(pn))
                 if m is None:
                     pass
@@ -178,7 +177,7 @@
         k, m, v = qlist[i]
         qlist[i] = '%s%s=%s' % (uq(k), m, uq(str(v)))
 
-    return join(qlist, '&')
+    return '&'.join(qlist) 
                 
 def make_hidden_input(*args, **kwargs):
     '''Construct a set of hidden input elements, with marshalling markup.
@@ -205,7 +204,7 @@
         qlist[i] = ('<input type="hidden" name="%s%s" value="%s">'
                     % (hq(k), m, hq(str(v))))
 
-    return join(qlist, '\n')
+    return '\n'.join(qlist)
                 
 def complex_marshal(pairs):
     '''Add request marshalling information to a list of name-value pairs.
@@ -274,7 +273,7 @@
     qs = request.get('QUERY_STRING', '')
     
     if qs and omit:
-        qsparts = split(qs, '&')
+        qsparts = qs.split('&')
 
         if isinstance(omit, StringType):
             omits = {omit: None}
@@ -286,17 +285,17 @@
 
         unq = urllib.unquote
         for i in range(len(qsparts)):
-            name = unq(split(qsparts[i], '=', 1)[0])
+            name = unq(qsparts[i].split('=', 1)[0])
             if omitted(name):
                 qsparts[i] = ''
-            name = split(name, ':', 1)[0]
+            name = name.split(':', 1)[0]
             if omitted(name):
                 qsparts[i] = ''
-            name = split(name, '.', 1)[0]
+            name = name.split('.', 1)[0]
             if omitted(name):
                 qsparts[i] = ''
             
-        qs = join(filter(None, qsparts), '&')
+        qs = '&'.join(filter(None, qsparts))
 
     # We alway append '?' since arguments will be appended to the URL
     return '%s?%s' % (base, qs)