[Zope-Checkins] CVS: Zope/lib/python/App - ApplicationManager.py:1.78 CacheManager.py:1.23 Common.py:1.11 Extensions.py:1.18 FactoryDispatcher.py:1.20 FindHomes.py:1.8 ImageFile.py:1.15 Management.py:1.56 Product.py:1.56 ProductContext.py:1.38 RefreshFuncs.py:1.4 Undo.py:1.28 tar.py:1.5 version_txt.py:1.7

Andreas Jung andreas@digicool.com
Thu, 7 Feb 2002 12:37:11 -0500


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

Modified Files:
	ApplicationManager.py CacheManager.py Common.py Extensions.py 
	FactoryDispatcher.py FindHomes.py ImageFile.py Management.py 
	Product.py ProductContext.py RefreshFuncs.py Undo.py tar.py 
	version_txt.py 
Log Message:
replace string module calls by string methods


=== Zope/lib/python/App/ApplicationManager.py 1.77 => 1.78 ===
 
 
-import sys,os,time,string,Globals, Acquisition, os, Undo
+import sys,os,time,Globals, Acquisition, os, Undo
 from Globals import DTMLFile
 from OFS.ObjectManager import ObjectManager
 from OFS.Folder import Folder
@@ -25,7 +25,7 @@
 from App.Dialogs import MessageDialog
 from Product import ProductFolder
 from version_txt import version_txt
-from StringIO import StringIO
+from cStringIO import StringIO
 from AccessControl import getSecurityManager
 import zLOG
 
@@ -360,7 +360,6 @@
         path_join=os.path.join
         isdir=os.path.isdir
         exists=os.path.exists
-        strip=string.strip
 
         product_dir=path_join(SOFTWARE_HOME,'Products')
         product_names=os.listdir(product_dir)
@@ -380,7 +379,7 @@
                 file=open(version_txt, 'r')
                 data=file.readline()
                 file.close()
-                info.append(strip(data))
+                info.append(data.strip())
         return info
 
 


=== Zope/lib/python/App/CacheManager.py 1.22 => 1.23 ===
 __version__='$Revision$'[11:-2]
 
-import Globals, time, sys, string
+import Globals, time, sys
 
 class CacheManager:
     """Cache management mix-in
@@ -190,8 +190,8 @@
         if REQUEST is not None:
             # format as text
             REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
-            return string.join(map(lambda (name, count): '%6d %s' %
-                                   (count, name), detail), '\n')
+            return '\n'.join(map(lambda (name, count): '%6d %s' %
+                                   (count, name), detail))
         else:
             # raw
             return detail
@@ -229,7 +229,7 @@
                     dict['conn_no'], `dict['oid']`, dict['rc'],
                     state, dict['klass'], idinfo))
             REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
-            return string.join(res, '\n')
+            return '\n'.join(res)
         else:
             # raw
             return detail


=== Zope/lib/python/App/Common.py 1.10 => 1.11 ===
 
 import sys, os, time
-from string import rfind
 
 
 # These are needed because the various date formats below must
@@ -98,7 +97,7 @@
     if hasattr(m,'__path__'):
         r=m.__path__[0]
     elif "." in __name__:
-        r=sys.modules[__name__[:rfind(__name__,'.')]].__path__[0]
+        r=sys.modules[__name__[:__name__.rfind('.')]].__path__[0]
     else:
         r=__name__
     return os.path.join(os.getcwd(), r)


=== Zope/lib/python/App/Extensions.py 1.17 => 1.18 ===
 __version__='$Revision$'[11:-2]
 
-from string import find, split
 import os, zlib, rotor, imp
 import Products
 path_split=os.path.split
@@ -79,7 +78,7 @@
         'The file name, %s, should be a simple file name' % name)
 
     if checkProduct:
-       l = find(name, '.')
+       l = name.find('.')
        if l > 0:
            p = name[:l]
            n = name[l + 1:]
@@ -128,7 +127,7 @@
         m=binmod.__dict__
 
     elif p[-4:]=='.pyp':
-        prod_id=split(module, '.')[0]
+        prod_id=module.split('.')[0]
         data=zlib.decompress(
             rotor.newrotor(prod_id +' shshsh').decrypt(open(p,'rb').read())
             )


=== Zope/lib/python/App/FactoryDispatcher.py 1.19 => 1.20 ===
 # Implement the manage_addProduct method of object managers
 import Acquisition, sys, Products
-from string import rfind
 from AccessControl.PermissionMapping import aqwrap
 from AccessControl.Owned import UnownableOwner
 
@@ -53,8 +52,8 @@
                 v=REQUEST['URL']
             except KeyError: pass
             else:
-                v=v[:rfind(v,'/')]
-                self._u=v[:rfind(v,'/')]
+                v=v[:v.rfind('/')]
+                self._u=v[:v.rfind('/')]
 
     def Destination(self):
         "Return the destination for factory output"


=== Zope/lib/python/App/FindHomes.py 1.7 => 1.8 ===
 __version__='$Revision$'[11:-2]
 
-import os, sys, Products, string
+import os, sys, Products
 from Common import package_home
 path_join = os.path.join
 path_split = os.path.split
@@ -63,7 +63,7 @@
 ippart = 0
 ppath = Products.__path__
 if os.path.isdir(ip) and ip not in ppath:
-    disallow=string.lower(os.environ.get('DISALLOW_LOCAL_PRODUCTS',''))
+    disallow=os.environ.get('DISALLOW_LOCAL_PRODUCTS','').lower()
     if disallow in ('no', 'off', '0', ''):
         ppath.insert(0, ip)
         ippart = 1
@@ -71,14 +71,14 @@
 ppathpat = os.environ.get('PRODUCTS_PATH', None)
 if ppathpat is not None:
     psep = os.pathsep
-    if string.find(ppathpat, '%(') >= 0:
-        newppath = string.split(ppathpat % {
-            'PRODUCTS_PATH': string.join(ppath, psep),
-            'SOFTWARE_PRODUCTS': string.join(ppath[ippart:], psep),
+    if ppathpat.find('%(') >= 0:
+        newppath = (ppathpat % {
+            'PRODUCTS_PATH': psep.join(ppath ),
+            'SOFTWARE_PRODUCTS': psep.join(ppath[ippart:] ),
             'INSTANCE_PRODUCTS': ip,
-            }, psep)
+            }).split(psep)
     else:
-        newppath = string.split(ppathpat, psep)
+        newppath = ppathpat.split(psep)
     del ppath[:]
     for p in filter(None, newppath):
         p = os.path.abspath(p)


=== Zope/lib/python/App/ImageFile.py 1.14 => 1.15 ===
 from Globals import package_home
 from Common import rfc1123_date
-from string import rfind, split
 from DateTime import DateTime
 from time import time
 from os import stat
 import Acquisition
-import string, os
+import  os
 
 
 class ImageFile(Acquisition.Explicit):
@@ -42,8 +41,8 @@
         if content_type:
             self.content_type=content_type
         else:
-            self.content_type='image/%s' % path[rfind(path,'.')+1:]
-        self.__name__=path[rfind(path,'/')+1:]
+            self.content_type='image/%s' % path[path.rfind('.')+1:]
+        self.__name__=path[path.rfind('/')+1:]
         self.lmt=float(stat(path)[8]) or time()
         self.lmh=rfc1123_date(self.lmt)
 
@@ -55,7 +54,7 @@
         # somewhere...
         header=REQUEST.get_header('If-Modified-Since', None)
         if header is not None:
-            header=string.split(header, ';')[0]
+            header=header.split(';')[0]
             # Some proxies seem to send invalid date strings for this
             # header. If the date string is not valid, we ignore it
             # rather than raise an error to be generally consistent


=== Zope/lib/python/App/Management.py 1.55 => 1.56 ===
 from Dialogs import MessageDialog
 from Globals import DTMLFile, HTMLFile
-from string import split, join, find
 from AccessControl import getSecurityManager, Unauthorized
 
 class Tabs(ExtensionClass.Base):
@@ -76,7 +75,7 @@
             raise Unauthorized, (
                 'You are not authorized to view this object.')
 
-        if find(m,'/'):
+        if m.find('/'):
             raise 'Redirect', (
                 "%s/%s" % (REQUEST['URL1'], m))
         
@@ -100,7 +99,7 @@
         script = '%s/%s' % (script, last)
         out.append('<a class="strong-link" href="%s/manage_workspace">%s</a>'%
                    (script, unquote(last)))
-        return '%s%s' % (url, join(out,'/'))
+        return '%s%s' % (url, '/'.join(out))
 
     def tabs_path_info(self, script, path,
                        # Static vars
@@ -111,7 +110,7 @@
         while path[-1:]=='/': path=path[:-1]
         while script[:1]=='/': script=script[1:]
         while script[-1:]=='/': script=script[:-1]
-        path=split(path,'/')[:-1]
+        path=path.split('/')[:-1]
         if script: path=[script]+path
         if not path: return ''
         script=''
@@ -121,7 +120,7 @@
             script="%s/%s" % (script, quote(p))
             out.append('<a href="%s/manage_workspace">%s</a>' % (script, p))
         out.append(last)
-        return join(out, '/')
+        return '/'.join(out)
 
     class_manage_path__roles__=None
     def class_manage_path(self):


=== Zope/lib/python/App/Product.py 1.55 => 1.56 ===
 
 
-import Globals, OFS.Folder, OFS.SimpleItem, os, string, Acquisition, Products
+import Globals, OFS.Folder, OFS.SimpleItem, os,  Acquisition, Products
 import re, zlib, Globals, cPickle, marshal, rotor
 import ZClasses, ZClasses.ZClass, AccessControl.Owned
 from urllib import quote
 
 from OFS.Folder import Folder
-from string import atoi, find, strip, join
 from Factory import Factory
 from Permission import PermissionManager
 import ZClasses, ZClasses.ZClass
@@ -180,7 +179,7 @@
         "Set the product up to create a distribution and give a link"
         if self.__dict__.has_key('manage_options'):
             raise TypeError, 'This product is <b>not</b> redistributable.'
-        self.version=version=strip(version)
+        self.version=version=version.strip()
         self.configurable_objects_=configurable_objects
         self.redistributable=redistributable
         RESPONSE.redirect('Distributions/%s-%s.tar.gz' %
@@ -256,7 +255,7 @@
 
         def __bobo_traverse__(self, REQUEST, name):
             if name[-7:] != '.tar.gz': raise 'Invalid Name', name
-            l=find(name,'-')
+            l=name.find('-')
             id, version = name[:l], name[l+1:-7]
             product=self.aq_parent
             if product.id==id and product.version==version:
@@ -425,7 +424,7 @@
 
     def getdata(self):
         self._r.append(self._rot.encryptmore(self._c.flush()))
-        return join(self._r,'')
+        return ''.join(self._r)
 
 class CompressedInputFile:
     _done=0
@@ -459,10 +458,10 @@
         return r
 
     def readline(self):
-        l=find(self._b, '\n')
+        l=self._b.find('\n')
         while l < 0 and not self._done:
             self._next()
-            l=find(self._b, '\n')
+            l=self._b.find('\n')
         if l < 0: l=len(self._b)
         else: l=l+1
         r=self._b[:l]
@@ -488,7 +487,7 @@
     if hasattr(productp, '__import_error__'): ie=productp.__import_error__
     else: ie=None
 
-    try: fver=strip(open(home+'/version.txt').read())
+    try: fver=open(home+'/version.txt').read().strip()
     except: fver=''
     old=None
     try:


=== Zope/lib/python/App/ProductContext.py 1.37 => 1.38 ===
 from FactoryDispatcher import FactoryDispatcher
 from zLOG import LOG, WARNING
-import string, os.path, re
+import os.path, re
 import stat
 from DateTime import DateTime
 from types import ListType, TupleType
@@ -210,8 +210,8 @@
             
         key="%s/%s" % (module, name)
 
-        if module[:9]=='Products.': module=string.split(module,'.')[1]
-        else: module=string.split(module,'.')[0]
+        if module[:9]=='Products.': module=module.split('.')[1]
+        else: module=module.split('.')[0]
             
         info="%s: %s" % (module, name)
 
@@ -293,7 +293,7 @@
 
         for file in os.listdir(path):
             ext=os.path.splitext(file)[1]
-            ext=string.lower(ext)
+            ext=ext.lower()
             if ext in ('.dtml',):
                 contents = open(os.path.join(path,file),'rb').read()
                 m = title_re.search(contents)
@@ -313,7 +313,7 @@
                 ht=HelpTopic.TextTopic(file, title, os.path.join(path,file))
                 self.registerHelpTopic(file, ht)
             elif ext in ('.stx', '.txt'):
-                title=string.split(open(os.path.join(path,file),'rb').readline(), ':')[0]
+                title=(open(os.path.join(path,file),'rb').readline()).split(':')[0]
                 ht=HelpTopic.STXTopic(file, title, os.path.join(path, file))
                 self.registerHelpTopic(file, ht)
             elif ext in ('.jpg', '.gif', '.png'):


=== Zope/lib/python/App/RefreshFuncs.py 1.3 => 1.4 ===
 import os, sys
 from time import time
-from string import split, join
 import Products
 from ExtensionClass import Base
 from Globals import PersistentMapping
@@ -255,7 +254,7 @@
         exists = os.path.exists
 
         for name, module in modlist:
-            splitname = split(name, '.')[2:]
+            splitname = name.split( '.')[2:]
             if not splitname:
                 filename = '__init__'
             else:


=== Zope/lib/python/App/Undo.py 1.27 => 1.28 ===
 import Globals, ExtensionClass
 from DateTime import DateTime
-from string import atof, find, atoi, split, rfind, join
 from AccessControl import getSecurityManager
 import base64
 
@@ -99,7 +98,7 @@
             desc = d['description']
             tid=d['id']
             if desc:
-                desc = split(desc)
+                desc = desc.split()
                 d1=desc[0]
                 desc = join(desc[1:])
                 if len(desc) > 60: desc = desc[:56]+' ...'
@@ -116,7 +115,7 @@
         """
         undo=Globals.UndoManager.undo
         for tid in transaction_info:
-            tid=split(tid)
+            tid=tid.split()
             if tid:
                 get_transaction().note("Undo %s" % join(tid[1:]))
                 tid=decode64(tid[0])


=== Zope/lib/python/App/tar.py 1.4 => 1.5 ===
     
 
-from string import find, join
-
 def oct8(i):
     i=oct(i)
     return '0'*(6-len(i))+i+' \0'
@@ -45,7 +43,7 @@
         "Initialize a Tar archive entry"
         self.data=data
         if mtime is None: mtime=int(time.time())
-        header=join([
+        header=''.join([
             pad(path,      100),
             oct8(mode),
             oct8(uid),
@@ -63,7 +61,7 @@
             '000000 \0',
             pad(prefix,    155),
             '\0'*12,
-            ], '')
+            ])
         if len(header) != 512: raise 'Bad Header Length', len(header)
         header=(header[:148]+
                 oct8(reduce(lambda a,b: a+b, map(ord,header)))+
@@ -82,7 +80,7 @@
     for name, data in entries:
         ra(str(TarEntry(name,data)))
     ra('\0'*1024)
-    return join(r,'')
+    return ''.join(r)
 
 def tgz(entries):
     c=zlib.compressobj()
@@ -93,7 +91,7 @@
         ra(compress(str(TarEntry(name,data))))
     ra(compress('\0'*1024))
     ra(c.flush())
-    return join(r,'')
+    return ''.join(r)
 
 class tgzarchive:
 
@@ -135,4 +133,4 @@
         append(self._c.flush())
         append(pack("<i", self._crc))
         append(pack("<i", self._l))
-        return join(r,'')
+        return ''.join(r)


=== Zope/lib/python/App/version_txt.py 1.6 => 1.7 ===
 ##############################################################################
 
-import os,sys,string,re
+import os,sys,re
 
 v=sys.version_info