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/freeze | |
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/freeze')
-rw-r--r-- | Tools/freeze/checkextensions.py | 7 | ||||
-rw-r--r-- | Tools/freeze/checkextensions_win32.py | 14 | ||||
-rwxr-xr-x | Tools/freeze/freeze.py | 13 | ||||
-rw-r--r-- | Tools/freeze/makefreeze.py | 5 | ||||
-rw-r--r-- | Tools/freeze/makemakefile.py | 5 | ||||
-rw-r--r-- | Tools/freeze/modulefinder.py | 13 | ||||
-rw-r--r-- | Tools/freeze/parsesetup.py | 11 | ||||
-rw-r--r-- | Tools/freeze/winmakemakefile.py | 4 |
8 files changed, 33 insertions, 39 deletions
diff --git a/Tools/freeze/checkextensions.py b/Tools/freeze/checkextensions.py index 8d597bf..584f8a6 100644 --- a/Tools/freeze/checkextensions.py +++ b/Tools/freeze/checkextensions.py @@ -3,7 +3,6 @@ # and one or more .o files or a lib.a file. import os -import string import parsesetup def checkextensions(unknown, extensions): @@ -44,7 +43,7 @@ def select(e, mods, vars, mod, skipofiles): if not w: continue w = expandvars(w, vars) - for w in string.split(w): + for w in w.split(): if skipofiles and w[-2:] == '.o': continue # Assume $var expands to absolute pathname @@ -73,14 +72,14 @@ def treatword(w): def expandvars(str, vars): i = 0 while i < len(str): - i = k = string.find(str, '$', i) + i = k = str.find('$', i) if i < 0: break i = i+1 var = str[i:i+1] i = i+1 if var == '(': - j = string.find(str, ')', i) + j = str.find(')', i) if j < 0: break var = str[i:j] diff --git a/Tools/freeze/checkextensions_win32.py b/Tools/freeze/checkextensions_win32.py index 85c3a3c..669a142 100644 --- a/Tools/freeze/checkextensions_win32.py +++ b/Tools/freeze/checkextensions_win32.py @@ -22,7 +22,7 @@ At the moment the name and location of this INI file is hardcoded, but an obvious enhancement would be to provide command line options. """ -import os, string, sys +import os, sys try: import win32api except ImportError: @@ -107,12 +107,12 @@ def get_extension_defn(moduleName, mapFileName, prefix): module.AddCompilerOption(win32api.ExpandEnvironmentStrings(cl_options)) exclude = win32api.GetProfileVal(moduleName, "exclude", "", mapFileName) - exclude = string.split(exclude) + exclude = exclude.split() if win32api.GetProfileVal(moduleName, "Unicode", 0, mapFileName): module.AddCompilerOption('/D UNICODE /D _UNICODE') - libs = string.split(win32api.GetProfileVal(moduleName, "libs", "", mapFileName)) + libs = win32api.GetProfileVal(moduleName, "libs", "", mapFileName).split() for lib in libs: module.AddLinkerLib(win32api.ExpandEnvironmentStrings(lib)) @@ -135,9 +135,9 @@ def parse_dsp(dsp): sys.stderr.write("%s: %s\n" % (dsp, msg)) return None for line in lines: - fields = string.split(string.strip(line), "=", 2) + fields = line.strip().split("=", 2) if fields[0]=="SOURCE": - if string.lower(os.path.splitext(fields[1])[1]) in ['.cpp', '.c']: + if os.path.splitext(fields[1])[1].lower() in ['.cpp', '.c']: ret.append( win32api.GetFullPathName(os.path.join(dsp_path, fields[1] ) ) ) return ret @@ -148,12 +148,12 @@ def write_extension_table(fname, modules): # Write fn protos for module in modules: # bit of a hack for .pyd's as part of packages. - name = string.split(module.name,'.')[-1] + name = module.name.split('.')[-1] fp.write('extern void init%s(void);\n' % (name) ) # Write the table fp.write (ext_tab_header) for module in modules: - name = string.split(module.name,'.')[-1] + name = module.name.split('.')[-1] fp.write('\t{"%s", init%s},\n' % (name, name) ) fp.write (ext_tab_footer) diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py index 0b9b206..2c59807 100755 --- a/Tools/freeze/freeze.py +++ b/Tools/freeze/freeze.py @@ -91,7 +91,6 @@ if it does, the resulting binary is not self-contained. import getopt import os -import string import sys @@ -148,7 +147,7 @@ def main(): # last option can not be "-i", so this ensures "pos+1" is in range! if sys.argv[pos] == '-i': try: - options = string.split(open(sys.argv[pos+1]).read()) + options = open(sys.argv[pos+1]).read().split() except IOError, why: usage("File name '%s' specified with the -i option " "can not be read - %s" % (sys.argv[pos+1], why) ) @@ -198,9 +197,9 @@ def main(): if o == '-l': addn_link.append(a) if o == '-a': - apply(modulefinder.AddPackagePath, tuple(string.split(a,"=", 2))) + apply(modulefinder.AddPackagePath, tuple(a.split("=", 2))) if o == '-r': - f,r = string.split(a,"=", 2) + f,r = a.split("=", 2) replace_paths.append( (f,r) ) # default prefix and exec_prefix @@ -419,7 +418,7 @@ def main(): # report unknown modules if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % - string.join(unknown)) + ' '.join(unknown)) # windows gets different treatment if win: @@ -462,8 +461,8 @@ def main(): for key in makevars.keys(): somevars[key] = makevars[key] - somevars['CFLAGS'] = string.join(cflags) # override - somevars['CPPFLAGS'] = string.join(cppflags) # override + somevars['CFLAGS'] = ' '.join(cflags) # override + somevars['CPPFLAGS'] = ' '.join(cppflags) # override files = [base_config_c, base_frozen_c] + \ files + supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] diff --git a/Tools/freeze/makefreeze.py b/Tools/freeze/makefreeze.py index 3888050..29a6ad6 100644 --- a/Tools/freeze/makefreeze.py +++ b/Tools/freeze/makefreeze.py @@ -1,5 +1,4 @@ import marshal -import string import bkfile @@ -38,7 +37,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()): mods.sort() for mod in mods: m = dict[mod] - mangled = string.join(string.split(mod, "."), "__") + mangled = "__".join(mod.split(".")) if m.__code__: file = 'M_' + mangled + '.c' outfp = bkfile.open(base + file, 'w') @@ -88,4 +87,4 @@ def writecode(outfp, mod, str): ## def writecode(outfp, mod, str): ## outfp.write('unsigned char M_%s[%d] = "%s";\n' % (mod, len(str), -## string.join(map(lambda s: `s`[1:-1], string.split(str, '"')), '\\"'))) +## '\\"'.join(map(lambda s: `s`[1:-1], str.split('"'))))) diff --git a/Tools/freeze/makemakefile.py b/Tools/freeze/makemakefile.py index e33e32e..b8b99b8 100644 --- a/Tools/freeze/makemakefile.py +++ b/Tools/freeze/makemakefile.py @@ -1,7 +1,6 @@ # Write the actual Makefile. import os -import string def makemakefile(outfp, makevars, files, target): outfp.write("# Makefile generated by freeze.py script\n\n") @@ -23,8 +22,8 @@ def makemakefile(outfp, makevars, files, target): files[i] = dest deps.append(dest) - outfp.write("\n%s: %s\n" % (target, string.join(deps))) + outfp.write("\n%s: %s\n" % (target, ' '.join(deps))) outfp.write("\t$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" % - (string.join(files), target)) + (' '.join(files), target)) outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target) diff --git a/Tools/freeze/modulefinder.py b/Tools/freeze/modulefinder.py index 741ef4d..e9c1140 100644 --- a/Tools/freeze/modulefinder.py +++ b/Tools/freeze/modulefinder.py @@ -5,7 +5,6 @@ import imp import marshal import os import re -import string import sys import new @@ -150,7 +149,7 @@ class ModuleFinder: self.msgout(4, "determine_parent ->", parent) return parent if '.' in pname: - i = string.rfind(pname, '.') + i = pname.rfind('.') pname = pname[:i] parent = self.modules[pname] assert parent.__name__ == pname @@ -162,7 +161,7 @@ class ModuleFinder: def find_head_package(self, parent, name): self.msgin(4, "find_head_package", parent, name) if '.' in name: - i = string.find(name, '.') + i = name.find('.') head = name[:i] tail = name[i+1:] else: @@ -190,7 +189,7 @@ class ModuleFinder: self.msgin(4, "load_tail", q, tail) m = q while tail: - i = string.find(tail, '.') + i = tail.find('.') if i < 0: i = len(tail) head, tail = tail[:i], tail[i+1:] mname = "%s.%s" % (m.__name__, head) @@ -357,7 +356,7 @@ class ModuleFinder: def find_module(self, name, path): if path: - fullname = string.join(path, '.')+'.'+name + fullname = '.'.join(path)+'.'+name else: fullname = name if fullname in self.excludes: @@ -399,7 +398,7 @@ class ModuleFinder: if key not in self.excludes: mods = self.badmodules[key].keys() mods.sort() - print "?", key, "from", string.join(mods, ', ') + print "?", key, "from", ', '.join(mods) def any_missing(self): keys = self.badmodules.keys() @@ -457,7 +456,7 @@ def test(): if o == '-m': domods = 1 if o == '-p': - addpath = addpath + string.split(a, os.pathsep) + addpath = addpath + a.split(os.pathsep) if o == '-q': debug = 0 if o == '-x': diff --git a/Tools/freeze/parsesetup.py b/Tools/freeze/parsesetup.py index 7a6b72e..2b9123e 100644 --- a/Tools/freeze/parsesetup.py +++ b/Tools/freeze/parsesetup.py @@ -1,7 +1,6 @@ # Parse Makefiles and Python Setup(.in) files. import re -import string # Extract variable definitions from a Makefile. @@ -29,10 +28,10 @@ def getmakevars(filename): continue (name, value) = matchobj.group(1, 2) # Strip trailing comment - i = string.find(value, '#') + i = value.find('#') if i >= 0: value = value[:i] - value = string.strip(value) + value = value.strip() variables[name] = value finally: fp.close() @@ -60,7 +59,7 @@ def getsetupinfo(filename): if not line: break # Strip comments - i = string.find(line, '#') + i = line.find('#') if i >= 0: line = line[:i] if line.endswith('\\\n'): @@ -69,9 +68,9 @@ def getsetupinfo(filename): matchobj = setupvardef.match(line) if matchobj: (name, value) = matchobj.group(1, 2) - variables[name] = string.strip(value) + variables[name] = value.strip() else: - words = string.split(line) + words = line.split() if words: modules[words[0]] = words[1:] finally: diff --git a/Tools/freeze/winmakemakefile.py b/Tools/freeze/winmakemakefile.py index d668a6e8..763e820 100644 --- a/Tools/freeze/winmakemakefile.py +++ b/Tools/freeze/winmakemakefile.py @@ -1,4 +1,4 @@ -import sys, os, string +import sys, os # Template used then the program is a GUI program WINMAINTEMPLATE = """ @@ -112,7 +112,7 @@ def realwork(vars, moddefns, target): print "\t\t$(cflags) $(cdebug) $(cinclude) \\" extra = moddefn.GetCompilerOptions() if extra: - print "\t\t%s \\" % (string.join(extra),) + print "\t\t%s \\" % (' '.join(extra),) print '\t\t"%s"' % file print |