diff options
author | Walter Dörwald <walter@livinglogic.de> | 2002-09-11 20:36:02 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2002-09-11 20:36:02 (GMT) |
commit | aaab30e00cc3e8d90c71b8657c284feeb4ac1413 (patch) | |
tree | d055e0bd374770014d9afdff1b961418b1828584 /Tools/scripts | |
parent | 6a0477b099560a452e37fe77c3850bf232487c16 (diff) | |
download | cpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.zip cpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.tar.gz cpython-aaab30e00cc3e8d90c71b8657c284feeb4ac1413.tar.bz2 |
Apply diff2.txt from SF patch http://www.python.org/sf/572113
(with one small bugfix in bgen/bgen/scantools.py)
This replaces string module functions with string methods
for the stuff in the Tools directory. Several uses of
string.letters etc. are still remaining.
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/byteyears.py | 5 | ||||
-rwxr-xr-x | Tools/scripts/checkappend.py | 3 | ||||
-rwxr-xr-x | Tools/scripts/classfix.py | 6 | ||||
-rwxr-xr-x | Tools/scripts/cvsfiles.py | 3 | ||||
-rwxr-xr-x | Tools/scripts/dutree.py | 8 | ||||
-rwxr-xr-x | Tools/scripts/fixcid.py | 11 | ||||
-rwxr-xr-x | Tools/scripts/fixheader.py | 5 | ||||
-rwxr-xr-x | Tools/scripts/ftpmirror.py | 11 | ||||
-rw-r--r-- | Tools/scripts/gencodec.py | 44 | ||||
-rwxr-xr-x | Tools/scripts/ifdef.py | 7 | ||||
-rwxr-xr-x | Tools/scripts/logmerge.py | 8 | ||||
-rwxr-xr-x | Tools/scripts/mailerdaemon.py | 17 | ||||
-rwxr-xr-x | Tools/scripts/methfix.py | 3 | ||||
-rwxr-xr-x | Tools/scripts/nm2def.py | 8 | ||||
-rwxr-xr-x | Tools/scripts/objgraph.py | 1 | ||||
-rwxr-xr-x | Tools/scripts/pathfix.py | 5 | ||||
-rwxr-xr-x | Tools/scripts/pdeps.py | 7 | ||||
-rwxr-xr-x | Tools/scripts/pindent.py | 11 | ||||
-rwxr-xr-x | Tools/scripts/rgrep.py | 3 | ||||
-rwxr-xr-x | Tools/scripts/sum5.py | 3 | ||||
-rw-r--r-- | Tools/scripts/trace.py | 23 | ||||
-rwxr-xr-x | Tools/scripts/treesync.py | 8 | ||||
-rwxr-xr-x | Tools/scripts/untabify.py | 3 | ||||
-rwxr-xr-x | Tools/scripts/which.py | 4 | ||||
-rwxr-xr-x | Tools/scripts/xxci.py | 3 |
25 files changed, 90 insertions, 120 deletions
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py index f67be70..2b0f9b2 100755 --- a/Tools/scripts/byteyears.py +++ b/Tools/scripts/byteyears.py @@ -7,7 +7,6 @@ # Options -[amc] select atime, mtime (default) or ctime as age. import sys, os, time -import string from stat import * # Use lstat() to stat files if it exists, else stat() @@ -51,7 +50,7 @@ for file in sys.argv[1:]: size = st[ST_SIZE] age = now - anytime byteyears = float(size) * float(age) / secs_per_year - print string.ljust(file, maxlen), - print string.rjust(`int(byteyears)`, 8) + print file.ljust(maxlen), + print repr(int(byteyears)).rjust(8) sys.exit(status) diff --git a/Tools/scripts/checkappend.py b/Tools/scripts/checkappend.py index c1188e2..b3141df 100755 --- a/Tools/scripts/checkappend.py +++ b/Tools/scripts/checkappend.py @@ -35,14 +35,13 @@ __version__ = 1, 0, 0 import os import sys -import string import getopt import tokenize verbose = 0 def errprint(*args): - msg = string.join(args) + msg = ' '.join(args) sys.stderr.write(msg) sys.stderr.write("\n") diff --git a/Tools/scripts/classfix.py b/Tools/scripts/classfix.py index 26aa599..7b86aa3 100755 --- a/Tools/scripts/classfix.py +++ b/Tools/scripts/classfix.py @@ -156,8 +156,6 @@ classprog = regex.compile(classexpr) baseexpr = '^ *\(.*\) *( *) *$' baseprog = regex.compile(baseexpr) -import string - def fixline(line): if classprog.match(line) < 0: # No 'class' keyword -- no change return line @@ -176,7 +174,7 @@ def fixline(line): basepart = line[a2+1:b2] # Extract list of base expressions - bases = string.splitfields(basepart, ',') + bases = basepart.split(',') # Strip trailing '()' from each base expression for i in range(len(bases)): @@ -185,7 +183,7 @@ def fixline(line): bases[i] = bases[i][x1:y1] # Join the bases back again and build the new line - basepart = string.joinfields(bases, ', ') + basepart = ', '.join(bases) return head + '(' + basepart + '):' + tail diff --git a/Tools/scripts/cvsfiles.py b/Tools/scripts/cvsfiles.py index d133a40..2168556 100755 --- a/Tools/scripts/cvsfiles.py +++ b/Tools/scripts/cvsfiles.py @@ -14,7 +14,6 @@ import os import sys import stat import getopt -import string cutofftime = 0 @@ -51,7 +50,7 @@ def process(dir): if cvsdir: entries = os.path.join(cvsdir, "Entries") for e in open(entries).readlines(): - words = string.split(e, '/') + words = e.split('/') if words[0] == '' and words[1:]: name = words[1] fullname = os.path.join(dir, name) diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py index 7a32533..35b3916 100755 --- a/Tools/scripts/dutree.py +++ b/Tools/scripts/dutree.py @@ -1,10 +1,10 @@ #! /usr/bin/env python # Format du output in a tree shape -import os, string, sys, errno +import os, sys, errno def main(): - p = os.popen('du ' + string.join(sys.argv[1:]), 'r') + p = os.popen('du ' + ' '.join(sys.argv[1:]), 'r') total, d = None, {} for line in p.readlines(): i = 0 @@ -12,7 +12,7 @@ def main(): size = eval(line[:i]) while line[i] in ' \t': i = i+1 file = line[i:-1] - comps = string.splitfields(file, '/') + comps = file.split('/') if comps[0] == '': comps[0] = '/' if comps[len(comps)-1] == '': del comps[len(comps)-1] total, d = store(size, comps, total, d) @@ -51,7 +51,7 @@ def show(total, d, prefix): if tsub is None: psub = prefix else: - print prefix + string.rjust(`tsub`, width) + ' ' + key + print prefix + repr(tsub).rjust(width) + ' ' + key psub = prefix + ' '*(width-1) + '|' + ' '*(len(key)+1) if d.has_key(key): show(tsub, d[key][1], psub) diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py index 6f674c6..8bc1de0 100755 --- a/Tools/scripts/fixcid.py +++ b/Tools/scripts/fixcid.py @@ -36,7 +36,6 @@ import sys import regex -import string import os from stat import * import getopt @@ -213,11 +212,11 @@ Number = Floatnumber + '\|' + Intnumber # Anything else is an operator -- don't list this explicitly because of '/*' OutsideComment = (Identifier, Number, String, Char, CommentStart) -OutsideCommentPattern = '\(' + string.joinfields(OutsideComment, '\|') + '\)' +OutsideCommentPattern = '\(' + '\|'.join(OutsideComment) + '\)' OutsideCommentProgram = regex.compile(OutsideCommentPattern) InsideComment = (Identifier, Number, CommentEnd) -InsideCommentPattern = '\(' + string.joinfields(InsideComment, '\|') + '\)' +InsideCommentPattern = '\(' + '\|'.join(InsideComment) + '\)' InsideCommentProgram = regex.compile(InsideCommentPattern) def initfixline(): @@ -286,10 +285,10 @@ def addsubst(substfile): if not line: break lineno = lineno + 1 try: - i = string.index(line, '#') - except string.index_error: + i = line.index('#') + except ValueError: i = -1 # Happens to delete trailing \n - words = string.split(line[:i]) + words = line[:i].split() if not words: continue if len(words) == 3 and words[0] == 'struct': words[:2] = [words[0] + ' ' + words[1]] diff --git a/Tools/scripts/fixheader.py b/Tools/scripts/fixheader.py index ba2e0c5..1f9c713 100755 --- a/Tools/scripts/fixheader.py +++ b/Tools/scripts/fixheader.py @@ -3,7 +3,6 @@ # Add some standard cpp magic to a header file import sys -import string def main(): args = sys.argv[1:] @@ -29,8 +28,8 @@ def process(file): sys.stderr.write('Processing %s ...\n' % file) magic = 'Py_' for c in file: - if c in string.ascii_letters + string.digits: - magic = magic + string.upper(c) + if ord(c)<=0x80 and c.isalnum(): + magic = magic + c.upper() else: magic = magic + '_' sys.stdout = f print '#ifndef', magic diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py index 38af9dc..c3469d0 100755 --- a/Tools/scripts/ftpmirror.py +++ b/Tools/scripts/ftpmirror.py @@ -22,7 +22,6 @@ import os import sys import time import getopt -import string import ftplib import netrc from fnmatch import fnmatch @@ -127,7 +126,7 @@ def mirrorsubdir(f, localdir): if mac: # Mac listing has just filenames; # trailing / means subdirectory - filename = string.strip(line) + filename = line.strip() mode = '-' if filename[-1:] == '/': filename = filename[:-1] @@ -135,12 +134,12 @@ def mirrorsubdir(f, localdir): infostuff = '' else: # Parse, assuming a UNIX listing - words = string.split(line, None, 8) + words = line.split(None, 8) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue - filename = string.lstrip(words[-1]) - i = string.find(filename, " -> ") + filename = words[-1].lstrip() + i = filename.find(" -> ") if i >= 0: # words[0] had better start with 'l'... if verbose > 1: @@ -360,7 +359,7 @@ class LoggingFile: def askabout(filetype, filename, pwd): prompt = 'Retrieve %s %s from %s ? [ny] ' % (filetype, filename, pwd) while 1: - reply = string.lower(string.strip(raw_input(prompt))) + reply = raw_input(prompt).strip().lower() if reply in ['y', 'ye', 'yes']: return 1 if reply in ['', 'n', 'no', 'nop', 'nope']: diff --git a/Tools/scripts/gencodec.py b/Tools/scripts/gencodec.py index 69b6ede..46563df 100644 --- a/Tools/scripts/gencodec.py +++ b/Tools/scripts/gencodec.py @@ -22,7 +22,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com). """#" -import string,re,os,time,marshal +import re,os,time,marshal # Create numeric tables or character based ones ? numeric = 1 @@ -34,9 +34,7 @@ mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)' '(#.+)?') def parsecodes(codes, - - split=string.split,atoi=string.atoi,len=len, - filter=filter,range=range): + len=len, filter=filter,range=range): """ Converts code combinations to either a single code integer or a tuple of integers. @@ -49,12 +47,12 @@ def parsecodes(codes, """ if not codes: return None - l = split(codes,'+') + l = codes.split('+') if len(l) == 1: - return atoi(l[0],16) + return int(l[0],16) for i in range(len(l)): try: - l[i] = atoi(l[i],16) + l[i] = int(l[i],16) except ValueError: l[i] = None l = filter(lambda x: x is not None, l) @@ -63,9 +61,7 @@ def parsecodes(codes, else: return tuple(l) -def readmap(filename, - - strip=string.strip): +def readmap(filename): f = open(filename,'r') lines = f.readlines() @@ -76,7 +72,7 @@ def readmap(filename, for i in range(256): unmapped[i] = i for line in lines: - line = strip(line) + line = line.strip() if not line or line[0] == '#': continue m = mapRE.match(line) @@ -108,9 +104,7 @@ def readmap(filename, return enc2uni -def hexrepr(t, - - join=string.join): +def hexrepr(t): if t is None: return 'None' @@ -118,11 +112,9 @@ def hexrepr(t, len(t) except: return '0x%04x' % t - return '(' + join(map(lambda t: '0x%04x' % t, t),', ') + ')' + return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')' -def unicoderepr(t, - - join=string.join): +def unicoderepr(t): if t is None: return 'None' @@ -133,11 +125,9 @@ def unicoderepr(t, len(t) except: return repr(unichr(t)) - return repr(join(map(unichr, t),'')) - -def keyrepr(t, + return repr(''.join(map(unichr, t))) - join=string.join): +def keyrepr(t): if t is None: return 'None' @@ -151,7 +141,7 @@ def keyrepr(t, return repr(chr(t)) else: return repr(unichr(t)) - return repr(join(map(chr, t),'')) + return repr(''.join(map(chr, t))) def codegen(name,map,comments=1): @@ -246,7 +236,7 @@ def getregentry(): encoding_map = codecs.make_encoding_map(decoding_map) ''') - return string.join(l,'\n') + return '\n'.join(l) def pymap(name,map,pyfile,comments=1): @@ -269,9 +259,9 @@ def convertdir(dir,prefix='',comments=1): mapnames = os.listdir(dir) for mapname in mapnames: name = os.path.split(mapname)[1] - name = string.replace(name,'-','_') - name = string.split(name, '.')[0] - name = string.lower(name) + name = name.replace('-','_') + name = name.split('.')[0] + name = name.lower() codefile = name + '.py' marshalfile = name + '.mapping' print 'converting %s to %s and %s' % (mapname, diff --git a/Tools/scripts/ifdef.py b/Tools/scripts/ifdef.py index da14437..c0c1459 100755 --- a/Tools/scripts/ifdef.py +++ b/Tools/scripts/ifdef.py @@ -29,7 +29,6 @@ import sys import regex import getopt -import string defs = [] undefs = [] @@ -62,12 +61,12 @@ def process(fpi, fpo): nextline = fpi.readline() if not nextline: break line = line + nextline - tmp = string.strip(line) + tmp = line.strip() if tmp[:1] != '#': if ok: fpo.write(line) continue - tmp = string.strip(tmp[1:]) - words = string.split(tmp) + tmp = tmp[1:].strip() + words = tmp.split() keyword = words[0] if keyword not in keywords: if ok: fpo.write(line) diff --git a/Tools/scripts/logmerge.py b/Tools/scripts/logmerge.py index d036749..d4c2fe6 100755 --- a/Tools/scripts/logmerge.py +++ b/Tools/scripts/logmerge.py @@ -24,7 +24,7 @@ from their output. """ -import os, sys, getopt, string, re +import os, sys, getopt, re sep1 = '='*77 + '\n' # file separator sep2 = '-'*28 + '\n' # revision separator @@ -84,7 +84,7 @@ def digest_chunk(chunk): keylen = len(key) for line in lines: if line[:keylen] == key: - working_file = string.strip(line[keylen:]) + working_file = line[keylen:].strip() break else: working_file = None @@ -93,7 +93,7 @@ def digest_chunk(chunk): revline = lines[0] dateline = lines[1] text = lines[2:] - words = string.split(dateline) + words = dateline.split() author = None if len(words) >= 3 and words[0] == 'date:': dateword = words[1] @@ -108,7 +108,7 @@ def digest_chunk(chunk): else: date = None text.insert(0, revline) - words = string.split(revline) + words = revline.split() if len(words) >= 2 and words[0] == 'revision': rev = words[1] else: diff --git a/Tools/scripts/mailerdaemon.py b/Tools/scripts/mailerdaemon.py index 113b376..85f90aa 100755 --- a/Tools/scripts/mailerdaemon.py +++ b/Tools/scripts/mailerdaemon.py @@ -1,6 +1,5 @@ """mailerdaemon - classes to parse mailer-daemon messages""" -import string import rfc822 import calendar import re @@ -18,9 +17,9 @@ class ErrorMessage(rfc822.Message): sub = self.getheader('Subject') if not sub: return 0 - sub = string.lower(sub) - if sub[:12] == 'waiting mail': return 1 - if string.find(sub, 'warning') >= 0: return 1 + sub = sub.lower() + if sub.startswith('waiting mail'): return 1 + if 'warning' in sub: return 1 self.sub = sub return 0 @@ -132,10 +131,10 @@ def emparse_list(fp, sub): if type(regexp) is type(''): for i in range(len(emails)-1,-1,-1): email = emails[i] - exp = re.compile(string.join(string.split(regexp, '<>'), re.escape(email)), re.MULTILINE) + exp = re.compile(re.escape(email).join(regexp.split('<>')), re.MULTILINE) res = exp.search(data) if res is not None: - errors.append(string.join(string.split(string.strip(email)+': '+res.group('reason')))) + errors.append(' '.join((email.strip()+': '+res.group('reason')).split())) del emails[i] continue res = regexp.search(data) @@ -143,14 +142,14 @@ def emparse_list(fp, sub): reason = res.group('reason') break for email in emails: - errors.append(string.join(string.split(string.strip(email)+': '+reason))) + errors.append(' '.join((email.strip()+': '+reason).split())) return errors EMPARSERS = [emparse_list, ] def sort_numeric(a, b): - a = string.atoi(a) - b = string.atoi(b) + a = int(a) + b = int(b) if a < b: return -1 elif a > b: return 1 else: return 0 diff --git a/Tools/scripts/methfix.py b/Tools/scripts/methfix.py index cbbb964..9e69961 100755 --- a/Tools/scripts/methfix.py +++ b/Tools/scripts/methfix.py @@ -30,7 +30,6 @@ import sys import regex import os from stat import * -import string err = sys.stderr.write dbg = err @@ -101,7 +100,7 @@ def fix(filename): return 1 if lineno == 1 and g is None and line[:2] == '#!': # Check for non-Python scripts - words = string.split(line[2:]) + words = line[2:].split() if words and regex.search('[pP]ython', words[0]) < 0: msg = filename + ': ' + words[0] msg = msg + ' script; not fixed\n' diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py index fc1022a..6887ee2 100755 --- a/Tools/scripts/nm2def.py +++ b/Tools/scripts/nm2def.py @@ -34,7 +34,7 @@ Even if this isn't the default output of your nm, there is generally an option to produce this format (since it is the original v7 Unix format). """ -import os,re,string,sys +import os,re,sys PYTHONLIB = 'libpython'+sys.version[:3]+'.a' PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll' @@ -43,12 +43,12 @@ NM = 'nm -p -g %s' # For Linux, use "nm -g %s" def symbols(lib=PYTHONLIB,types=('T','C','D')): lines = os.popen(NM % lib).readlines() - lines = map(string.strip,lines) + lines = [s.strip() for s in lines] symbols = {} for line in lines: if len(line) == 0 or ':' in line: continue - items = string.split(line) + items = line.split() if len(items) != 3: continue address, type, name = items @@ -69,7 +69,7 @@ def export_list(symbols): data.sort() data.append('') code.sort() - return string.join(data,' DATA\n')+'\n'+string.join(code,'\n') + return ' DATA\n'.join(data)+'\n'+'\n'.join(code) # Definition file template DEF_TEMPLATE = """\ diff --git a/Tools/scripts/objgraph.py b/Tools/scripts/objgraph.py index e25e5b8..3e040b9 100755 --- a/Tools/scripts/objgraph.py +++ b/Tools/scripts/objgraph.py @@ -20,7 +20,6 @@ import sys -import string import os import getopt import regex diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py index e1c6e73..81c5a6e 100755 --- a/Tools/scripts/pathfix.py +++ b/Tools/scripts/pathfix.py @@ -23,7 +23,6 @@ import sys import regex import os from stat import * -import string import getopt err = sys.stderr.write @@ -140,9 +139,9 @@ def fix(filename): return 0 def fixline(line): - if line[:2] != '#!': + if not line.startswith('#!'): return line - if string.find(line, "python") < 0: + if "python" not in line: return line return '#! %s\n' % new_interpreter diff --git a/Tools/scripts/pdeps.py b/Tools/scripts/pdeps.py index 18b582b..1589709 100755 --- a/Tools/scripts/pdeps.py +++ b/Tools/scripts/pdeps.py @@ -23,7 +23,6 @@ import sys import regex import os -import string # Main program @@ -82,10 +81,10 @@ def process(filename, table): elif m_from.match(line) >= 0: (a, b), (a1, b1) = m_from.regs[:2] else: continue - words = string.splitfields(line[a1:b1], ',') + words = line[a1:b1].split(',') # print '#', line, words for word in words: - word = string.strip(word) + word = word.strip() if word not in list: list.append(word) @@ -152,7 +151,7 @@ def printresults(table): for mod in modules: list = table[mod] list.sort() - print string.ljust(mod, maxlen), ':', + print mod.ljust(maxlen), ':', if mod in list: print '(*)', for ref in list: diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py index 318c20e..75175dc 100755 --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -83,7 +83,6 @@ EXPANDTABS = 0 import os import re -import string import sys next = {} @@ -119,7 +118,7 @@ class PythonIndenter: def write(self, line): if self.expandtabs: - self._write(string.expandtabs(line, self.tabsize)) + self._write(line.expandtabs(self.tabsize)) else: self._write(line) # end if @@ -270,7 +269,7 @@ class PythonIndenter: thiskw = '' # end if # end if - indent = len(string.expandtabs(line[:i], self.tabsize)) + indent = len(line[:i].expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -370,7 +369,7 @@ class StringReader: return r # end def read def readline(self): - i = string.find(self.buf, '\n', self.pos) + i = self.buf.find('\n', self.pos) return self.read(i + 1 - self.pos) # end def readline def readlines(self): @@ -514,9 +513,9 @@ def test(): # end if action = 'reformat' elif o == '-s': - stepsize = string.atoi(a) + stepsize = int(a) elif o == '-t': - tabsize = string.atoi(a) + tabsize = int(a) elif o == '-e': expandtabs = 1 # end if diff --git a/Tools/scripts/rgrep.py b/Tools/scripts/rgrep.py index 0271242..b644206 100755 --- a/Tools/scripts/rgrep.py +++ b/Tools/scripts/rgrep.py @@ -7,7 +7,6 @@ Usage: rgrep [-i] pattern file import sys import re -import string import getopt def main(): @@ -38,7 +37,7 @@ def main(): pos = pos - size f.seek(pos) buffer = f.read(size) - lines = string.split(buffer, "\n") + lines = buffer.split("\n") del buffer if leftover is None: if not lines[-1]: diff --git a/Tools/scripts/sum5.py b/Tools/scripts/sum5.py index 3efcc74..4250dde 100755 --- a/Tools/scripts/sum5.py +++ b/Tools/scripts/sum5.py @@ -16,7 +16,6 @@ file ... : files to sum; '-' or no files means stdin """ % bufsize import sys -import string import os import md5 import regsub @@ -89,7 +88,7 @@ def main(args = sys.argv[1:], out = sys.stdout): if o == '-t': rmode = 'r' if o == '-s': - bufsize = string.atoi(a) + bufsize = int(a) if not args: args = ['-'] return sum(args, out) diff --git a/Tools/scripts/trace.py b/Tools/scripts/trace.py index f96e04f..38e985e 100644 --- a/Tools/scripts/trace.py +++ b/Tools/scripts/trace.py @@ -83,7 +83,7 @@ Sample use, programmatically trace.print_results(show_missing=1) """ -import sys, os, string, tempfile, types, copy, operator, inspect, exceptions, marshal +import sys, os, tempfile, types, copy, operator, inspect, exceptions, marshal try: import cPickle pickle = cPickle @@ -177,7 +177,7 @@ class Ignore: # or # d = "/usr/local.py" # filename = "/usr/local.py" - if string.find(filename, d + os.sep) == 0: + if filename.startswith(d + os.sep): self._ignore[modulename] = 1 return 1 @@ -341,13 +341,12 @@ class CoverageResults: # '#pragma: NO COVER' (it is possible to embed this into # the text as a non-comment; no easy fix) if executable_linenos.has_key(i+1) and \ - string.find(lines[i], - string.join(['#pragma', 'NO COVER'])) == -1: + lines[i].find(' '.join(['#pragma', 'NO COVER'])) == -1: outfile.write('>>>>>> ') else: outfile.write(' '*7) n_lines = n_lines + 1 - outfile.write(string.expandtabs(lines[i], 8)) + outfile.write(lines[i].expandtabs(8)) outfile.close() @@ -675,16 +674,16 @@ def main(argv=None): continue if opt == "--ignore-dir": - for s in string.split(val, os.pathsep): + for s in val.split(os.pathsep): s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) - s = string.replace(s, "$prefix", - os.path.join(sys.prefix, "lib", - "python" + sys.version[:3])) - s = string.replace(s, "$exec_prefix", - os.path.join(sys.exec_prefix, "lib", - "python" + sys.version[:3])) + s = s.replace("$prefix", + os.path.join(sys.prefix, "lib", + "python" + sys.version[:3])) + s = s.replace("$exec_prefix", + os.path.join(sys.exec_prefix, "lib", + "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) continue diff --git a/Tools/scripts/treesync.py b/Tools/scripts/treesync.py index 96beba0..1064ab7 100755 --- a/Tools/scripts/treesync.py +++ b/Tools/scripts/treesync.py @@ -23,7 +23,7 @@ entry in the master tree are synchronized. This means: """ -import os, sys, stat, string, getopt +import os, sys, stat, getopt # Interactivity options default_answer = "ask" @@ -97,7 +97,7 @@ def process(slave, master): if cvsdir: entries = os.path.join(cvsdir, "Entries") for e in open(entries).readlines(): - words = string.split(e, '/') + words = e.split('/') if words[0] == '' and words[1:]: name = words[1] s = os.path.join(slave, name) @@ -188,10 +188,10 @@ def copy(src, dst, rmode="rb", wmode="wb", answer='ask'): g.close() def okay(prompt, answer='ask'): - answer = string.lower(string.strip(answer)) + answer = answer.strip().lower() if not answer or answer[0] not in 'ny': answer = raw_input(prompt) - answer = string.lower(string.strip(answer)) + answer = answer.strip().lower() if not answer: answer = default_answer if answer[:1] == 'y': diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py index 7be9f38..5eaf50e 100755 --- a/Tools/scripts/untabify.py +++ b/Tools/scripts/untabify.py @@ -4,7 +4,6 @@ import os import sys -import string import getopt def main(): @@ -32,7 +31,7 @@ def process(file, tabsize): except IOError, msg: print "%s: I/O error: %s" % (`file`, str(msg)) return - newtext = string.expandtabs(text, tabsize) + newtext = text.expandtabs(tabsize) if newtext == text: return backup = file + "~" diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py index 96e242c..19e3203 100755 --- a/Tools/scripts/which.py +++ b/Tools/scripts/which.py @@ -7,13 +7,13 @@ import sys if sys.path[0] in (".", ""): del sys.path[0] -import sys, os, string +import sys, os from stat import * def msg(str): sys.stderr.write(str + '\n') -pathlist = string.splitfields(os.environ['PATH'], ':') +pathlist = os.environ['PATH'].split(':') sts = 0 longlist = '' diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py index 2567bc5..681ce0b 100755 --- a/Tools/scripts/xxci.py +++ b/Tools/scripts/xxci.py @@ -9,7 +9,6 @@ import os from stat import * import commands import fnmatch -import string EXECMAGIC = '\001\140\000\010' @@ -57,7 +56,7 @@ def setup(): f = open('.xxcign', 'r') except IOError: return - ignore[:] = ignore + string.split(f.read()) + ignore[:] = ignore + f.read().split() def skipfile(file): for p in ignore: |