mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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
This commit is contained in:
parent
ff11334927
commit
9d72bb452b
69 changed files with 396 additions and 2113 deletions
|
@ -7,7 +7,7 @@ distribution)."""
|
|||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
import os, string
|
||||
import os
|
||||
from types import *
|
||||
from distutils.core import Command
|
||||
from distutils.errors import *
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] == '-':
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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' ?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue