summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-04-17 08:48:32 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-04-17 08:48:32 (GMT)
commit9d72bb452bced3a100f07f8a9e30c4495a9ec41a (patch)
treec39762a764fcc16f2cfc42e2504e58ff31e159e6 /Lib/distutils
parentff11334927ee616d765b54a3851016b76a20bcec (diff)
downloadcpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.zip
cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.gz
cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.bz2
Remove functions in string module that are also string methods. Also remove:
* all calls to functions in the string module (except maketrans) * everything from stropmodule except for maketrans() which is still used
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/cmd.py6
-rw-r--r--Lib/distutils/command/bdist.py2
-rw-r--r--Lib/distutils/command/bdist_msi.py2
-rw-r--r--Lib/distutils/command/bdist_rpm.py18
-rw-r--r--Lib/distutils/command/bdist_wininst.py10
-rw-r--r--Lib/distutils/command/build_clib.py5
-rw-r--r--Lib/distutils/command/build_ext.py24
-rw-r--r--Lib/distutils/command/build_py.py14
-rw-r--r--Lib/distutils/command/config.py10
-rw-r--r--Lib/distutils/command/install.py12
-rw-r--r--Lib/distutils/command/install_lib.py2
-rw-r--r--Lib/distutils/command/register.py4
-rw-r--r--Lib/distutils/command/sdist.py6
-rw-r--r--Lib/distutils/cygwinccompiler.py5
-rw-r--r--Lib/distutils/dist.py24
-rw-r--r--Lib/distutils/emxccompiler.py5
-rw-r--r--Lib/distutils/extension.py6
-rw-r--r--Lib/distutils/fancy_getopt.py14
-rw-r--r--Lib/distutils/filelist.py16
-rw-r--r--Lib/distutils/msvccompiler.py22
-rw-r--r--Lib/distutils/mwerkscompiler.py6
-rw-r--r--Lib/distutils/spawn.py12
-rw-r--r--Lib/distutils/sysconfig.py7
-rw-r--r--Lib/distutils/text_file.py22
-rw-r--r--Lib/distutils/util.py26
-rw-r--r--Lib/distutils/version.py17
26 files changed, 145 insertions, 152 deletions
diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py
index be0a3e2..ebd9931 100644
--- a/Lib/distutils/cmd.py
+++ b/Lib/distutils/cmd.py
@@ -8,7 +8,7 @@ in the distutils.command package.
__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, re
from types import *
from distutils.errors import *
from distutils import util, dir_util, file_util, archive_util, dep_util
@@ -166,7 +166,7 @@ class Command:
print(indent + header)
indent = indent + " "
for (option, _, _) in self.user_options:
- option = string.translate(option, longopt_xlate)
+ option = option.translate(longopt_xlate)
if option[-1] == "=":
option = option[:-1]
value = getattr(self, option)
@@ -415,7 +415,7 @@ class Command:
"""
if exec_msg is None:
exec_msg = "generating %s from %s" % \
- (outfile, string.join(infiles, ', '))
+ (outfile, ', '.join(infiles))
if skip_msg is None:
skip_msg = "skipping %s (inputs unchanged)" % outfile
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 23c25a5..d6897d2 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -7,7 +7,7 @@ distribution)."""
__revision__ = "$Id$"
-import os, string
+import os
from types import *
from distutils.core import Command
from distutils.errors import *
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index 75db877..f31bded 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -7,7 +7,7 @@
Implements the bdist_msi command.
"""
-import sys, os, string
+import sys, os
from distutils.core import Command
from distutils.util import get_platform
from distutils.dir_util import remove_tree
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index bbcf292..ef2bdfd 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -7,7 +7,7 @@ distributions)."""
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
import glob
from types import *
from distutils.core import Command
@@ -354,7 +354,7 @@ class bdist_rpm (Command):
line = out.readline()
if not line:
break
- l = string.split(string.strip(line))
+ l = line.strip().split()
assert(len(l) == 2)
binary_rpms.append(l[1])
# The source rpm is named after the first entry in the spec file
@@ -437,9 +437,9 @@ class bdist_rpm (Command):
'Conflicts',
'Obsoletes',
):
- val = getattr(self, string.lower(field))
+ val = getattr(self, field.lower())
if type(val) is ListType:
- spec_file.append('%s: %s' % (field, string.join(val)))
+ spec_file.append('%s: %s' % (field, ' '.join(val)))
elif val is not None:
spec_file.append('%s: %s' % (field, val))
@@ -452,7 +452,7 @@ class bdist_rpm (Command):
if self.build_requires:
spec_file.append('BuildRequires: ' +
- string.join(self.build_requires))
+ ' '.join(self.build_requires))
if self.icon:
spec_file.append('Icon: ' + os.path.basename(self.icon))
@@ -513,7 +513,7 @@ class bdist_rpm (Command):
'',
'%' + rpm_opt,])
if val:
- spec_file.extend(string.split(open(val, 'r').read(), '\n'))
+ spec_file.extend(open(val, 'r').read().split('\n'))
else:
spec_file.append(default)
@@ -526,7 +526,7 @@ class bdist_rpm (Command):
])
if self.doc_files:
- spec_file.append('%doc ' + string.join(self.doc_files))
+ spec_file.append('%doc ' + ' '.join(self.doc_files))
if self.changelog:
spec_file.extend([
@@ -544,8 +544,8 @@ class bdist_rpm (Command):
if not changelog:
return changelog
new_changelog = []
- for line in string.split(string.strip(changelog), '\n'):
- line = string.strip(line)
+ for line in changelog.strip().split('\n'):
+ line = line.strip()
if line[0] == '*':
new_changelog.extend(['', line])
elif line[0] == '-':
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 49afca0..21465a8 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -7,7 +7,7 @@ exe-program."""
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from distutils.core import Command
from distutils.util import get_platform
from distutils.dir_util import create_tree, remove_tree
@@ -135,7 +135,7 @@ class bdist_wininst (Command):
# Use a custom scheme for the zip-file, because we have to decide
# at installation time which scheme to use.
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
- value = string.upper(key)
+ value = key.upper()
if key == 'headers':
value = value + '/Include/$dist_name'
setattr(install,
@@ -192,14 +192,14 @@ class bdist_wininst (Command):
# Escape newline characters
def escape(s):
- return string.replace(s, "\n", "\\n")
+ return s.replace("\n", "\\n")
for name in ["author", "author_email", "description", "maintainer",
"maintainer_email", "name", "url", "version"]:
data = getattr(metadata, name, "")
if data:
info = info + ("\n %s: %s" % \
- (string.capitalize(name), escape(data)))
+ (name.capitalize(), escape(data)))
lines.append("%s=%s" % (name, escape(data)))
# The [setup] section contains entries controlling
@@ -220,7 +220,7 @@ class bdist_wininst (Command):
build_info = "Built %s with distutils-%s" % \
(time.ctime(time.time()), distutils.__version__)
lines.append("build_info=%s" % build_info)
- return string.join(lines, "\n")
+ return "\n".join(lines)
# get_inidata()
diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py
index 69d8c75..07f5817 100644
--- a/Lib/distutils/command/build_clib.py
+++ b/Lib/distutils/command/build_clib.py
@@ -18,7 +18,7 @@ __revision__ = "$Id$"
# two modules, mainly because a number of subtle details changed in the
# cut 'n paste. Sigh.
-import os, string
+import os
from types import *
from distutils.core import Command
from distutils.errors import *
@@ -93,8 +93,7 @@ class build_clib (Command):
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
if type(self.include_dirs) is StringType:
- self.include_dirs = string.split(self.include_dirs,
- os.pathsep)
+ self.include_dirs = self.include_dirs.split(os.pathsep)
# XXX same as for build_ext -- what about 'self.define' and
# 'self.undef' ?
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index bbe5146..d0cd162 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -8,7 +8,7 @@ extensions ASAP)."""
__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, re
from types import *
from distutils.core import Command
from distutils.errors import *
@@ -138,7 +138,7 @@ class build_ext (Command):
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
if type(self.include_dirs) is StringType:
- self.include_dirs = string.split(self.include_dirs, os.pathsep)
+ self.include_dirs = self.include_dirs.split(os.pathsep)
# Put the Python "system" include dir at the end, so that
# any local include dirs take precedence.
@@ -156,12 +156,12 @@ class build_ext (Command):
if self.library_dirs is None:
self.library_dirs = []
elif type(self.library_dirs) is StringType:
- self.library_dirs = string.split(self.library_dirs, os.pathsep)
+ self.library_dirs = self.library_dirs.split(os.pathsep)
if self.rpath is None:
self.rpath = []
elif type(self.rpath) is StringType:
- self.rpath = string.split(self.rpath, os.pathsep)
+ self.rpath = self.rpath.split(os.pathsep)
# for extensions under windows use different directories
# for Release and Debug builds.
@@ -186,7 +186,7 @@ class build_ext (Command):
# for extensions under Cygwin and AtheOS Python's library directory must be
# appended to library_dirs
if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
- if string.find(sys.executable, sys.exec_prefix) != -1:
+ if sys.executable.find(sys.exec_prefix) != -1:
# building third party extensions
self.library_dirs.append(os.path.join(sys.prefix, "lib",
"python" + get_python_version(),
@@ -199,7 +199,7 @@ class build_ext (Command):
# Python's library directory must be appended to library_dirs
if (sys.platform.startswith('linux') or sys.platform.startswith('gnu')) \
and sysconfig.get_config_var('Py_ENABLE_SHARED'):
- if string.find(sys.executable, sys.exec_prefix) != -1:
+ if sys.executable.find(sys.exec_prefix) != -1:
# building third party extensions
self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
else:
@@ -212,14 +212,14 @@ class build_ext (Command):
# symbols can be separated with commas.
if self.define:
- defines = string.split(self.define, ',')
+ defines = self.define.split(',')
self.define = map(lambda symbol: (symbol, '1'), defines)
# The option for macros to undefine is also a string from the
# option parsing, but has to be a list. Multiple symbols can also
# be separated with commas here.
if self.undef:
- self.undef = string.split(self.undef, ',')
+ self.undef = self.undef.split(',')
if self.swig_opts is None:
self.swig_opts = []
@@ -429,8 +429,8 @@ class build_ext (Command):
# ignore build-lib -- put the compiled extension into
# the source tree along with pure Python modules
- modpath = string.split(fullname, '.')
- package = string.join(modpath[0:-1], '.')
+ modpath = fullname.split('.')
+ package = '.'.join(modpath[0:-1])
base = modpath[-1]
build_py = self.get_finalized_command('build_py')
@@ -617,7 +617,7 @@ class build_ext (Command):
"""
from distutils.sysconfig import get_config_var
- ext_path = string.split(ext_name, '.')
+ ext_path = ext_name.split('.')
# OS/2 has an 8 character module (extension) limit :-(
if os.name == "os2":
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
@@ -634,7 +634,7 @@ class build_ext (Command):
the .pyd file (DLL) must export the module "init" function.
"""
- initfunc_name = "init" + string.split(ext.name,'.')[-1]
+ initfunc_name = "init" + ext.name.split('.')[-1]
if initfunc_name not in ext.export_symbols:
ext.export_symbols.append(initfunc_name)
return ext.export_symbols
diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
index 3b7ec62..990824b 100644
--- a/Lib/distutils/command/build_py.py
+++ b/Lib/distutils/command/build_py.py
@@ -6,7 +6,7 @@ Implements the Distutils 'build_py' command."""
__revision__ = "$Id$"
-import sys, string, os
+import sys, os
from types import *
from glob import glob
@@ -150,7 +150,7 @@ class build_py (Command):
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any)."""
- path = string.split(package, '.')
+ path = package.split('.')
if not self.package_dir:
if path:
@@ -161,7 +161,7 @@ class build_py (Command):
tail = []
while path:
try:
- pdir = self.package_dir[string.join(path, '.')]
+ pdir = self.package_dir['.'.join(path)]
except KeyError:
tail.insert(0, path[-1])
del path[-1]
@@ -272,8 +272,8 @@ class build_py (Command):
# - don't check for __init__.py in directory for empty package
for module in self.py_modules:
- path = string.split(module, '.')
- package = string.join(path[0:-1], '.')
+ path = module.split('.')
+ package = '.'.join(path[0:-1])
module_base = path[-1]
try:
@@ -342,7 +342,7 @@ class build_py (Command):
modules = self.find_all_modules()
outputs = []
for (package, module, module_file) in modules:
- package = string.split(package, '.')
+ package = package.split('.')
filename = self.get_module_outfile(self.build_lib, package, module)
outputs.append(filename)
if include_bytecode:
@@ -362,7 +362,7 @@ class build_py (Command):
def build_module (self, module, module_file, package):
if type(package) is StringType:
- package = string.split(package, '.')
+ package = package.split('.')
elif type(package) not in (ListType, TupleType):
raise TypeError, \
"'package' must be a string (dot-separated), list, or tuple"
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index 4246569..3374db9 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -13,7 +13,7 @@ this header file lives".
__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, re
from types import *
from distutils.core import Command
from distutils.errors import DistutilsExecError
@@ -74,7 +74,7 @@ class config (Command):
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
elif type(self.include_dirs) is StringType:
- self.include_dirs = string.split(self.include_dirs, os.pathsep)
+ self.include_dirs = self.include_dirs.split(os.pathsep)
if self.libraries is None:
self.libraries = []
@@ -84,7 +84,7 @@ class config (Command):
if self.library_dirs is None:
self.library_dirs = []
elif type(self.library_dirs) is StringType:
- self.library_dirs = string.split(self.library_dirs, os.pathsep)
+ self.library_dirs = self.library_dirs.split(os.pathsep)
def run (self):
@@ -163,7 +163,7 @@ class config (Command):
if not filenames:
filenames = self.temp_files
self.temp_files = []
- log.info("removing: %s", string.join(filenames))
+ log.info("removing: %s", ' '.join(filenames))
for filename in filenames:
try:
os.remove(filename)
@@ -322,7 +322,7 @@ class config (Command):
else:
body.append(" %s;" % func)
body.append("}")
- body = string.join(body, "\n") + "\n"
+ body = "\n".join(body) + "\n"
return self.try_link(body, headers, include_dirs,
libraries, library_dirs)
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index fd5d6d1..c03a90e 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -8,7 +8,7 @@ from distutils import log
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from types import *
from distutils.core import Command
from distutils.debug import DEBUG
@@ -269,7 +269,7 @@ class install (Command):
# $platbase in the other installation directories and not worry
# about needing recursive variable expansion (shudder).
- py_version = (string.split(sys.version))[0]
+ py_version = sys.version.split()[0]
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
self.config_vars = {'dist_name': self.distribution.get_name(),
'dist_version': self.distribution.get_version(),
@@ -353,11 +353,11 @@ class install (Command):
if opt_name[-1] == "=":
opt_name = opt_name[0:-1]
if self.negative_opt.has_key(opt_name):
- opt_name = string.translate(self.negative_opt[opt_name],
- longopt_xlate)
+ opt_name = self.negative_opt[opt_name].translate(
+ longopt_xlate)
val = not getattr(self, opt_name)
else:
- opt_name = string.translate(opt_name, longopt_xlate)
+ opt_name = opt_name.translate(longopt_xlate)
val = getattr(self, opt_name)
print(" %s: %s" % (opt_name, val))
@@ -464,7 +464,7 @@ class install (Command):
if self.extra_path is not None:
if type(self.extra_path) is StringType:
- self.extra_path = string.split(self.extra_path, ',')
+ self.extra_path = self.extra_path.split(',')
if len(self.extra_path) == 1:
path_file = extra_dirs = self.extra_path[0]
diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
index 08ff543..65d25f7 100644
--- a/Lib/distutils/command/install_lib.py
+++ b/Lib/distutils/command/install_lib.py
@@ -2,7 +2,7 @@
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from types import IntType
from distutils.core import Command
from distutils.errors import DistutilsOptionError
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 48070ee..3356798 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -7,7 +7,7 @@ Implements the Distutils 'register' command (register with the repository).
__revision__ = "$Id$"
-import sys, os, string, urllib2, getpass, urlparse
+import sys, os, urllib2, getpass, urlparse
import StringIO, ConfigParser
from distutils.core import Command
@@ -67,7 +67,7 @@ class register(Command):
if missing:
self.warn("missing required meta-data: " +
- string.join(missing, ", "))
+ ", ".join(missing))
if metadata.author:
if not metadata.author_email:
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index eb2db50..8e1c066 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -6,7 +6,7 @@ Implements the Distutils 'sdist' command (create a source distribution)."""
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from types import *
from glob import glob
from distutils.core import Command
@@ -166,7 +166,7 @@ class sdist (Command):
if missing:
self.warn("missing required meta-data: " +
- string.join(missing, ", "))
+ ", ".join(missing))
if metadata.author:
if not metadata.author_email:
@@ -279,7 +279,7 @@ class sdist (Command):
if not got_it:
self.warn("standard file not found: should have one of " +
- string.join(alts, ', '))
+ ', '.join(alts))
else:
if os.path.exists(fn):
self.filelist.append(fn)
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 44b5850..fae6848 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -365,10 +365,9 @@ def check_config_h():
# "pyconfig.h" check -- should probably be renamed...
from distutils import sysconfig
- import string
# if sys.version contains GCC then python was compiled with
# GCC, and the pyconfig.h file should be OK
- if string.find(sys.version,"GCC") >= 0:
+ if sys.version.find("GCC") >= 0:
return (CONFIG_H_OK, "sys.version mentions 'GCC'")
fn = sysconfig.get_config_h_filename()
@@ -387,7 +386,7 @@ def check_config_h():
else:
# "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
- if string.find(s,"__GNUC__") >= 0:
+ if s.find("__GNUC__") >= 0:
return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
else:
return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index ca7a2f9..7ed1b5c 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -8,7 +8,7 @@ being built/installed/distributed.
__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, re
from types import *
from copy import copy
@@ -304,7 +304,7 @@ Common commands: (see '--help-commands' for more)
else:
print(indent + "option dict for '%s' command:" % cmd_name)
out = pformat(opt_dict)
- for line in string.split(out, "\n"):
+ for line in out.split("\n"):
print(indent + " " + line)
# dump_option_dicts ()
@@ -378,7 +378,7 @@ Common commands: (see '--help-commands' for more)
for opt in options:
if opt != '__name__':
val = parser.get(section,opt)
- opt = string.replace(opt, '-', '_')
+ opt = opt.replace('-', '_')
opt_dict[opt] = (filename, val)
# Make the ConfigParser forget everything (so we retain
@@ -599,14 +599,14 @@ Common commands: (see '--help-commands' for more)
keywords = self.metadata.keywords
if keywords is not None:
if type(keywords) is StringType:
- keywordlist = string.split(keywords, ',')
- self.metadata.keywords = map(string.strip, keywordlist)
+ keywordlist = keywords.split(',')
+ self.metadata.keywords = [x.strip() for x in keywordlist]
platforms = self.metadata.platforms
if platforms is not None:
if type(platforms) is StringType:
- platformlist = string.split(platforms, ',')
- self.metadata.platforms = map(string.strip, platformlist)
+ platformlist = platforms.split(',')
+ self.metadata.platforms = [x.strip() for x in platformlist]
def _show_help (self,
parser,
@@ -695,10 +695,10 @@ Common commands: (see '--help-commands' for more)
opt = translate_longopt(opt)
value = getattr(self.metadata, "get_"+opt)()
if opt in ['keywords', 'platforms']:
- print(string.join(value, ','))
+ print(','.join(value))
elif opt in ('classifiers', 'provides', 'requires',
'obsoletes'):
- print(string.join(value, '\n'))
+ print('\n'.join(value))
else:
print(value)
any_display_options = 1
@@ -803,9 +803,9 @@ Common commands: (see '--help-commands' for more)
"""Return a list of packages from which commands are loaded."""
pkgs = self.command_packages
if not isinstance(pkgs, type([])):
- pkgs = string.split(pkgs or "", ",")
+ pkgs = (pkgs or "").split(",")
for i in range(len(pkgs)):
- pkgs[i] = string.strip(pkgs[i])
+ pkgs[i] = pkgs[i].strip()
pkgs = filter(None, pkgs)
if "distutils.command" not in pkgs:
pkgs.insert(0, "distutils.command")
@@ -1100,7 +1100,7 @@ class DistributionMetadata:
long_desc = rfc822_escape( self.get_long_description() )
file.write('Description: %s\n' % long_desc)
- keywords = string.join( self.get_keywords(), ',')
+ keywords = ','.join(self.get_keywords())
if keywords:
file.write('Keywords: %s\n' % keywords )
diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py
index 8aef2b7..f4b90dc 100644
--- a/Lib/distutils/emxccompiler.py
+++ b/Lib/distutils/emxccompiler.py
@@ -261,10 +261,9 @@ def check_config_h():
# "pyconfig.h" check -- should probably be renamed...
from distutils import sysconfig
- import string
# if sys.version contains GCC then python was compiled with
# GCC, and the pyconfig.h file should be OK
- if string.find(sys.version,"GCC") >= 0:
+ if sys.version.find("GCC") >= 0:
return (CONFIG_H_OK, "sys.version mentions 'GCC'")
fn = sysconfig.get_config_h_filename()
@@ -283,7 +282,7 @@ def check_config_h():
else:
# "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
- if string.find(s,"__GNUC__") >= 0:
+ if s.find("__GNUC__") >= 0:
return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
else:
return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py
index 440d128..0fcbcc1 100644
--- a/Lib/distutils/extension.py
+++ b/Lib/distutils/extension.py
@@ -5,7 +5,7 @@ modules in setup scripts."""
__revision__ = "$Id$"
-import os, string, sys
+import os, sys
from types import *
try:
@@ -128,7 +128,7 @@ class Extension:
if len(kw):
L = kw.keys() ; L.sort()
L = map(repr, L)
- msg = "Unknown Extension options: " + string.join(L, ', ')
+ msg = "Unknown Extension options: " + ', '.join(L)
if warnings is not None:
warnings.warn(msg)
else:
@@ -195,7 +195,7 @@ def read_setup_file (filename):
elif switch == "-I":
ext.include_dirs.append(value)
elif switch == "-D":
- equals = string.find(value, "=")
+ equals = value.find("=")
if equals == -1: # bare "-DFOO" -- no value
ext.define_macros.append((value, None))
else: # "-DFOO=blah"
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index 646f8e1..317a3a4 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -115,7 +115,7 @@ class FancyGetopt:
"""Translate long option name 'long_option' to the form it
has as an attribute of some object: ie., translate hyphens
to underscores."""
- return string.translate(long_option, longopt_xlate)
+ return long_option.translate(longopt_xlate)
def _check_alias_dict (self, aliases, what):
@@ -253,7 +253,7 @@ class FancyGetopt:
self._grok_option_table()
- short_opts = string.join(self.short_opts)
+ short_opts = ' '.join(self.short_opts)
try:
opts, args = getopt.getopt(args, short_opts, self.long_opts)
except getopt.error as msg:
@@ -420,8 +420,8 @@ def wrap_text (text, width):
if len(text) <= width:
return [text]
- text = string.expandtabs(text)
- text = string.translate(text, WS_TRANS)
+ text = text.expandtabs()
+ text = text.translate(WS_TRANS)
chunks = re.split(r'( +|-+)', text)
chunks = filter(None, chunks) # ' - ' results in empty strings
lines = []
@@ -460,7 +460,7 @@ def wrap_text (text, width):
# and store this line in the list-of-all-lines -- as a single
# string, of course!
- lines.append(string.join(cur_line, ''))
+ lines.append(''.join(cur_line))
# while chunks
@@ -473,7 +473,7 @@ def translate_longopt (opt):
"""Convert a long option name to a valid Python identifier by
changing "-" to "_".
"""
- return string.translate(opt, longopt_xlate)
+ return opt.translate(longopt_xlate)
class OptionDummy:
@@ -498,5 +498,5 @@ say, "How should I know?"].)"""
for w in (10, 20, 30, 40):
print("width: %d" % w)
- print(string.join(wrap_text(text, w), "\n"))
+ print("\n".join(wrap_text(text, w)))
print()
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py
index e4a83d6..bc668cf 100644
--- a/Lib/distutils/filelist.py
+++ b/Lib/distutils/filelist.py
@@ -8,7 +8,7 @@ and building lists of files.
__revision__ = "$Id$"
-import os, string, re
+import os, re
import fnmatch
from types import *
from glob import glob
@@ -84,7 +84,7 @@ class FileList:
# -- "File template" methods ---------------------------------------
def _parse_template_line (self, line):
- words = string.split(line)
+ words = line.split()
action = words[0]
patterns = dir = dir_pattern = None
@@ -133,28 +133,28 @@ class FileList:
# right number of words on the line for that action -- so we
# can proceed with minimal error-checking.
if action == 'include':
- self.debug_print("include " + string.join(patterns))
+ self.debug_print("include " + ' '.join(patterns))
for pattern in patterns:
if not self.include_pattern(pattern, anchor=1):
log.warn("warning: no files found matching '%s'",
pattern)
elif action == 'exclude':
- self.debug_print("exclude " + string.join(patterns))
+ self.debug_print("exclude " + ' '.join(patterns))
for pattern in patterns:
if not self.exclude_pattern(pattern, anchor=1):
log.warn(("warning: no previously-included files "
"found matching '%s'"), pattern)
elif action == 'global-include':
- self.debug_print("global-include " + string.join(patterns))
+ self.debug_print("global-include " + ' '.join(patterns))
for pattern in patterns:
if not self.include_pattern(pattern, anchor=0):
log.warn(("warning: no files found matching '%s' " +
"anywhere in distribution"), pattern)
elif action == 'global-exclude':
- self.debug_print("global-exclude " + string.join(patterns))
+ self.debug_print("global-exclude " + ' '.join(patterns))
for pattern in patterns:
if not self.exclude_pattern(pattern, anchor=0):
log.warn(("warning: no previously-included files matching "
@@ -163,7 +163,7 @@ class FileList:
elif action == 'recursive-include':
self.debug_print("recursive-include %s %s" %
- (dir, string.join(patterns)))
+ (dir, ' '.join(patterns)))
for pattern in patterns:
if not self.include_pattern(pattern, prefix=dir):
log.warn(("warning: no files found matching '%s' " +
@@ -172,7 +172,7 @@ class FileList:
elif action == 'recursive-exclude':
self.debug_print("recursive-exclude %s %s" %
- (dir, string.join(patterns)))
+ (dir, ' '.join(patterns)))
for pattern in patterns:
if not self.exclude_pattern(pattern, prefix=dir):
log.warn(("warning: no previously-included files matching "
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 968a4ff..ca1feaa 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -12,7 +12,7 @@ for the Microsoft Visual Studio.
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from distutils.errors import \
DistutilsExecError, DistutilsPlatformError, \
CompileError, LibError, LinkError
@@ -148,7 +148,7 @@ you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
def sub(self, s):
for k, v in self.macros.items():
- s = string.replace(s, k, v)
+ s = s.replace(k, v)
return s
def get_build_version():
@@ -159,7 +159,7 @@ def get_build_version():
"""
prefix = "MSC v."
- i = string.find(sys.version, prefix)
+ i = sys.version.find(prefix)
if i == -1:
return 6
i = i + len(prefix)
@@ -181,10 +181,10 @@ def get_build_architecture():
"""
prefix = " bit ("
- i = string.find(sys.version, prefix)
+ i = sys.version.find(prefix)
if i == -1:
return "Intel"
- j = string.find(sys.version, ")", i)
+ j = sys.version.find(")", i)
return sys.version[i+len(prefix):j]
@@ -266,11 +266,11 @@ class MSVCCompiler (CCompiler) :
# extend the MSVC path with the current path
try:
- for p in string.split(os.environ['path'], ';'):
+ for p in os.environ['path'].split(';'):
self.__paths.append(p)
except KeyError:
pass
- os.environ['path'] = string.join(self.__paths, ';')
+ os.environ['path'] = ';'.join(self.__paths)
self.preprocess_options = None
if self.__arch == "Intel":
@@ -579,7 +579,7 @@ class MSVCCompiler (CCompiler) :
return fn
# didn't find it; try existing path
- for p in string.split(os.environ['Path'],';'):
+ for p in os.environ['Path'].split(';'):
fn = os.path.join(os.path.abspath(p),exe)
if os.path.isfile(fn):
return fn
@@ -608,9 +608,9 @@ class MSVCCompiler (CCompiler) :
d = read_values(base, key)
if d:
if self.__version >= 7:
- return string.split(self.__macros.sub(d[path]), ";")
+ return self.__macros.sub(d[path]).split(";")
else:
- return string.split(d[path], ";")
+ return d[path].split(";")
# MSVC 6 seems to create the registry entries we need only when
# the GUI is run.
if self.__version == 6:
@@ -635,4 +635,4 @@ class MSVCCompiler (CCompiler) :
else:
p = self.get_msvc_paths(name)
if p:
- os.environ[name] = string.join(p, ';')
+ os.environ[name] = ';'.join(p)
diff --git a/Lib/distutils/mwerkscompiler.py b/Lib/distutils/mwerkscompiler.py
index 9db1a39..028ea82 100644
--- a/Lib/distutils/mwerkscompiler.py
+++ b/Lib/distutils/mwerkscompiler.py
@@ -8,7 +8,7 @@ Windows."""
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from types import *
from distutils.errors import \
DistutilsExecError, DistutilsPlatformError, \
@@ -213,11 +213,11 @@ class MWerksCompiler (CCompiler) :
curdir = os.getcwd()
filename = os.path.join(curdir, filename)
# Finally remove .. components
- components = string.split(filename, ':')
+ components = filename.split(':')
for i in range(1, len(components)):
if components[i] == '..':
components[i] = ''
- return string.join(components, ':')
+ return ':'.join(components)
def library_dir_option (self, dir):
"""Return the compiler option to add 'dir' to the list of
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index c75931c..c70c10b 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -10,7 +10,7 @@ executable name.
__revision__ = "$Id$"
-import sys, os, string
+import sys, os
from distutils.errors import *
from distutils import log
@@ -59,7 +59,7 @@ def _nt_quote_args (args):
# quoting?)
for i in range(len(args)):
- if string.find(args[i], ' ') != -1:
+ if args[i].find(' ') != -1:
args[i] = '"%s"' % args[i]
return args
@@ -73,7 +73,7 @@ def _spawn_nt (cmd,
if search_path:
# either we find one or it stays the same
executable = find_executable(executable) or executable
- log.info(string.join([executable] + cmd[1:], ' '))
+ log.info(' '.join([executable] + cmd[1:]))
if not dry_run:
# spawn for NT requires a full path to the .exe
try:
@@ -98,7 +98,7 @@ def _spawn_os2 (cmd,
if search_path:
# either we find one or it stays the same
executable = find_executable(executable) or executable
- log.info(string.join([executable] + cmd[1:], ' '))
+ log.info(' '.join([executable] + cmd[1:]))
if not dry_run:
# spawnv for OS/2 EMX requires a full path to the .exe
try:
@@ -119,7 +119,7 @@ def _spawn_posix (cmd,
verbose=0,
dry_run=0):
- log.info(string.join(cmd, ' '))
+ log.info(' '.join(cmd))
if dry_run:
return
exec_fn = search_path and os.execvp or os.execv
@@ -184,7 +184,7 @@ def find_executable(executable, path=None):
"""
if path is None:
path = os.environ['PATH']
- paths = string.split(path, os.pathsep)
+ paths = path.split(os.pathsep)
(base, ext) = os.path.splitext(executable)
if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
executable = executable + '.exe'
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 220b033..ea2e059 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -13,7 +13,6 @@ __revision__ = "$Id$"
import os
import re
-import string
import sys
from .errors import DistutilsPlatformError
@@ -261,7 +260,7 @@ def parse_makefile(fn, g=None):
m = _variable_rx.match(line)
if m:
n, v = m.group(1, 2)
- v = string.strip(v)
+ v = v.strip()
if "$" in v:
notdone[n] = v
else:
@@ -295,7 +294,7 @@ def parse_makefile(fn, g=None):
else:
try: value = int(value)
except ValueError:
- done[name] = string.strip(value)
+ done[name] = value.strip()
else:
done[name] = value
del notdone[name]
@@ -399,7 +398,7 @@ def _init_posix():
# relative to the srcdir, which after installation no longer makes
# sense.
python_lib = get_python_lib(standard_lib=1)
- linkerscript_path = string.split(g['LDSHARED'])[0]
+ linkerscript_path = g['LDSHARED'].split()[0]
linkerscript_name = os.path.basename(linkerscript_path)
linkerscript = os.path.join(python_lib, 'config',
linkerscript_name)
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 10ee1be..c23a31d 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -7,7 +7,7 @@ lines, and joining lines with backslashes."""
__revision__ = "$Id$"
from types import *
-import sys, os, string
+import sys, os
class TextFile:
@@ -142,7 +142,7 @@ class TextFile:
else:
outmsg.append("line %d: " % line)
outmsg.append(str(msg))
- return string.join(outmsg, "")
+ return "".join(outmsg)
def error (self, msg, line=None):
@@ -196,7 +196,7 @@ class TextFile:
# unescape it (and any other escaped "#"'s that might be
# lurking in there) and otherwise leave the line alone.
- pos = string.find (line, "#")
+ pos = line.find ("#")
if pos == -1: # no "#" -- no comments
pass
@@ -219,11 +219,11 @@ class TextFile:
# # comment that should be ignored
# there
# result in "hello there".
- if string.strip(line) == "":
+ if line.strip () == "":
continue
else: # it's an escaped "#"
- line = string.replace (line, "\\#", "#")
+ line = line.replace("\\#", "#")
# did previous line end with a backslash? then accumulate
@@ -235,7 +235,7 @@ class TextFile:
return buildup_line
if self.collapse_join:
- line = string.lstrip (line)
+ line = line.lstrip ()
line = buildup_line + line
# careful: pay attention to line number when incrementing it
@@ -259,11 +259,11 @@ class TextFile:
# strip whitespace however the client wants (leading and
# trailing, or one or the other, or neither)
if self.lstrip_ws and self.rstrip_ws:
- line = string.strip (line)
+ line = line.strip ()
elif self.lstrip_ws:
- line = string.lstrip (line)
+ line = line.lstrip ()
elif self.rstrip_ws:
- line = string.rstrip (line)
+ line = line.rstrip ()
# blank line (whether we rstrip'ed or not)? skip to next line
# if appropriate
@@ -313,7 +313,7 @@ line 3 \\
continues on next line
"""
# result 1: no fancy options
- result1 = map (lambda x: x + "\n", string.split (test_data, "\n")[0:-1])
+ result1 = map (lambda x: x + "\n", test_data.split ("\n")[0:-1])
# result 2: just strip comments
result2 = ["\n",
@@ -340,7 +340,7 @@ line 3 \\
def test_input (count, description, file, expected_result):
result = file.readlines ()
- # result = string.join (result, '')
+ # result = ''.join (result)
if result == expected_result:
print("ok %d (%s)" % (count, description))
else:
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 16d8bcb..6f15ce8 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -42,10 +42,9 @@ def get_platform ():
# Convert the OS name to lowercase, remove '/' characters
# (to accommodate BSD/OS), and translate spaces (for "Power Macintosh")
- osname = string.lower(osname)
- osname = string.replace(osname, '/', '')
- machine = string.replace(machine, ' ', '_')
- machine = string.replace(machine, '/', '-')
+ osname = osname.lower().replace('/', '')
+ machine = machine.replace(' ', '_')
+ machine = machine.replace('/', '-')
if osname[:5] == "linux":
# At least on Linux/Intel, 'machine' is the processor --
@@ -139,7 +138,7 @@ def convert_path (pathname):
if pathname[-1] == '/':
raise ValueError, "path '%s' cannot end with '/'" % pathname
- paths = string.split(pathname, '/')
+ paths = pathname.split('/')
while '.' in paths:
paths.remove('.')
if not paths:
@@ -178,7 +177,7 @@ def change_root (new_root, pathname):
return os.path.join(new_root, pathname)
else:
# Chop off volume name from start of path
- elements = string.split(pathname, ":", 1)
+ elements = pathname.split(":", 1)
pathname = ":" + elements[1]
return os.path.join(new_root, pathname)
@@ -281,7 +280,7 @@ def split_quoted (s):
# bit of a brain-bender to get it working right, though...
if _wordchars_re is None: _init_regex()
- s = string.strip(s)
+ s = s.strip()
words = []
pos = 0
@@ -294,7 +293,7 @@ def split_quoted (s):
if s[end] in string.whitespace: # unescaped, unquoted whitespace: now
words.append(s[:end]) # we definitely have a word delimiter
- s = string.lstrip(s[end:])
+ s = s[end:].lstrip()
pos = 0
elif s[end] == '\\': # preserve whatever is being escaped;
@@ -354,7 +353,7 @@ def strtobool (val):
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
- val = string.lower(val)
+ val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
@@ -445,7 +444,7 @@ files = [
#if prefix:
# prefix = os.path.abspath(prefix)
- script.write(string.join(map(repr, py_files), ",\n") + "]\n")
+ script.write(",\n".join(map(repr, py_files)) + "]\n")
script.write("""
byte_compile(files, optimize=%r, force=%r,
prefix=%r, base_dir=%r,
@@ -507,7 +506,6 @@ def rfc822_escape (header):
"""Return a version of the string escaped for inclusion in an
RFC-822 header, by ensuring there are 8 spaces space after each newline.
"""
- lines = string.split(header, '\n')
- lines = map(string.strip, lines)
- header = string.join(lines, '\n' + 8*' ')
- return header
+ lines = [x.strip() for x in header.split('\n')]
+ sep = '\n' + 8*' '
+ return sep.join(lines)
diff --git a/Lib/distutils/version.py b/Lib/distutils/version.py
index 2cd3636..2db6b18 100644
--- a/Lib/distutils/version.py
+++ b/Lib/distutils/version.py
@@ -26,8 +26,7 @@ Every version number class implements the following interface:
of the same class, thus must follow the same rules)
"""
-import string, re
-from types import StringType
+import re
class Version:
"""Abstract base class for version numbering classes. Just provides
@@ -147,12 +146,12 @@ class StrictVersion (Version):
match.group(1, 2, 4, 5, 6)
if patch:
- self.version = tuple(map(string.atoi, [major, minor, patch]))
+ self.version = tuple(map(int, [major, minor, patch]))
else:
- self.version = tuple(map(string.atoi, [major, minor]) + [0])
+ self.version = tuple(map(int, [major, minor]) + [0])
if prerelease:
- self.prerelease = (prerelease[0], string.atoi(prerelease_num))
+ self.prerelease = (prerelease[0], int(prerelease_num))
else:
self.prerelease = None
@@ -160,9 +159,9 @@ class StrictVersion (Version):
def __str__ (self):
if self.version[2] == 0:
- vstring = string.join(map(str, self.version[0:2]), '.')
+ vstring = '.'.join(map(str, self.version[0:2]))
else:
- vstring = string.join(map(str, self.version), '.')
+ vstring = '.'.join(map(str, self.version))
if self.prerelease:
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
@@ -171,7 +170,7 @@ class StrictVersion (Version):
def __cmp__ (self, other):
- if isinstance(other, StringType):
+ if isinstance(other, str):
other = StrictVersion(other)
compare = cmp(self.version, other.version)
@@ -327,7 +326,7 @@ class LooseVersion (Version):
def __cmp__ (self, other):
- if isinstance(other, StringType):
+ if isinstance(other, str):
other = LooseVersion(other)
return cmp(self.version, other.version)