changeset 1180:c1c0d7f6f2b4

remove string module usage, some other cosmetic changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 13 Aug 2006 23:43:20 +0200
parents f82f71d052cd
children a7f8dceb4410
files MoinMoin/script/account/check.py MoinMoin/search/queryparser.py MoinMoin/support/BasicAuthTransport.py MoinMoin/support/xapwrap/document.py MoinMoin/userform.py setup.py
diffstat 6 files changed, 14 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/account/check.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/MoinMoin/script/account/check.py	Sun Aug 13 23:43:20 2006 +0200
@@ -189,12 +189,11 @@
                 self.process(uids)
 
     def make_WikiNames(self):
-        import string
         for uid, u in self.users.items():
             if u.disabled:
                 continue
             if not wikiutil.isStrictWikiname(u.name):
-                newname = string.capwords(u.name).replace(" ", "").replace("-", "")
+                newname = u.name.capwords().replace(" ", "").replace("-", "")
                 if not wikiutil.isStrictWikiname(newname):
                     print " %-20s %-30r - no WikiName, giving up" % (uid, u.name)
                 else:
--- a/MoinMoin/search/queryparser.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/MoinMoin/search/queryparser.py	Sun Aug 13 23:43:20 2006 +0200
@@ -10,7 +10,7 @@
     @license: GNU GPL, see COPYING for details
 """
 
-import re, string
+import re
 from MoinMoin import config
 from MoinMoin.search.results import Match, TitleMatch, TextMatch
 
--- a/MoinMoin/support/BasicAuthTransport.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/MoinMoin/support/BasicAuthTransport.py	Sun Aug 13 23:43:20 2006 +0200
@@ -1,13 +1,13 @@
 # taken from Amos' XML-RPC HowTo:
 
-import string, xmlrpclib, httplib
+import xmlrpclib, httplib
 from base64 import encodestring
 
 class BasicAuthTransport(xmlrpclib.Transport):
     def __init__(self, username=None, password=None):
-        self.username=username
-        self.password=password
-        self.verbose=0
+        self.username = username
+        self.password = password
+        self.verbose = 0
 
     def request(self, host, handler, request_body, **kw):
         # issue XML-RPC request
@@ -21,13 +21,10 @@
         h.putheader("User-Agent", self.user_agent)
         h.putheader("Content-Type", "text/xml")
         h.putheader("Content-Length", str(len(request_body)))
-        #h.putheader("Connection", "close") # TW XXX just trying if that cures twisted ...
 
         # basic auth
         if self.username is not None and self.password is not None:
-            authhdr = "Basic %s" % string.replace(
-                    encodestring("%s:%s" % (self.username, self.password)),
-                    "\012", "")
+            authhdr = "Basic %s" % encodestring("%s:%s" % (self.username, self.password)).replace("\012", "")
             h.putheader("Authorization", authhdr)
         h.endheaders()
 
@@ -43,5 +40,5 @@
                 headers
                 )
 
-        return self.parse_response(h.getfile()) 
+        return self.parse_response(h.getfile())
 
--- a/MoinMoin/support/xapwrap/document.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/MoinMoin/support/xapwrap/document.py	Sun Aug 13 23:43:20 2006 +0200
@@ -1,7 +1,6 @@
 """
     xapwrap.document - Pythonic wrapper around Xapian's Document API
 """
-import string
 import datetime
 import re
 import cPickle
--- a/MoinMoin/userform.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/MoinMoin/userform.py	Sun Aug 13 23:43:20 2006 +0200
@@ -6,7 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import string, time, re
+import time, re
 from MoinMoin import user, util, wikiutil
 from MoinMoin.util import web, timefuncs
 from MoinMoin.widget import html
@@ -359,8 +359,8 @@
                 '%s [%s%s:%s]' % (
                     time.strftime(self.cfg.datetime_fmt, timefuncs.tmtuple(t)),
                     "+-"[offset < 0],
-                    string.zfill("%d" % (abs(offset) / 3600), 2),
-                    string.zfill("%d" % (abs(offset) % 3600 / 60), 2),
+                    "%02d" % (abs(offset) / 3600),
+                    "%02d" % (abs(offset) % 3600 / 60),
                 ),
             ))
 
--- a/setup.py	Sun Aug 13 23:16:34 2006 +0200
+++ b/setup.py	Sun Aug 13 23:43:20 2006 +0200
@@ -8,7 +8,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import glob, os, string, sys
+import os, sys, glob
 
 import distutils
 from distutils.core import setup
@@ -135,8 +135,6 @@
             raise Exception("You have to inherit build_scripts_create and"
                 " provide a package name")
 
-        to_module = string.maketrans('-/', '_.')
-
         self.mkpath(self.build_dir)
         for script in self.scripts:
             outfile = os.path.join(self.build_dir, os.path.basename(script))
@@ -150,7 +148,7 @@
                 continue
 
             module = os.path.splitext(os.path.basename(script))[0]
-            module = string.translate(module, to_module)
+            module = module.replace('-', '_').replace('/', '.')
             script_vars = {
                 'python': os.path.normpath(sys.executable),
                 'package': self.package_name,
@@ -189,7 +187,7 @@
         module files.
     """
     script = os.path.splitext(os.path.basename(path))[0]
-    script = string.replace(script, '_', '-')
+    script = script.replace('_', '-')
     if sys.platform == "win32":
         script = script + ".bat"
     return script