Kaydet (Commit) cb1f4c4d authored tarafından Greg Ward's avatar Greg Ward

Standardized whitespace around function calls.

üst 963cd2d8
......@@ -132,7 +132,7 @@ class bdist (Command):
# keep its temporary files around so subsequent runs go faster.
if cmd_name in commands[i+1:]:
sub_cmd.keep_temp = 1
self.run_command (cmd_name)
self.run_command(cmd_name)
# run()
......
......@@ -71,24 +71,24 @@ class bdist_dumb (Command):
def run (self):
self.run_command ('build')
self.run_command('build')
install = self.reinitialize_command('install', reinit_subcommands=1)
install.root = self.bdist_dir
self.announce ("installing to %s" % self.bdist_dir)
self.announce("installing to %s" % self.bdist_dir)
self.run_command('install')
# And make an archive relative to the root of the
# pseudo-installation tree.
archive_basename = "%s.%s" % (self.distribution.get_fullname(),
self.plat_name)
self.make_archive (os.path.join(self.dist_dir, archive_basename),
self.format,
root_dir=self.bdist_dir)
self.make_archive(os.path.join(self.dist_dir, archive_basename),
self.format,
root_dir=self.bdist_dir)
if not self.keep_temp:
remove_tree (self.bdist_dir, self.verbose, self.dry_run)
remove_tree(self.bdist_dir, self.verbose, self.dry_run)
# run()
......
......@@ -258,7 +258,7 @@ class bdist_rpm (Command):
# Make a source distribution and copy to SOURCES directory with
# optional icon.
sdist = self.reinitialize_command ('sdist')
sdist = self.reinitialize_command('sdist')
if self.use_bzip2:
sdist.formats = ['bztar']
else:
......
......@@ -56,8 +56,8 @@ class bdist_wininst (Command):
if self.distribution.has_ext_modules():
short_version = sys.version[:3]
if self.target_version and self.target_version != short_version:
raise DistutilsOptionError ("target version can only be" +
short_version)
raise DistutilsOptionError, \
"target version can only be" + short_version
self.target_version = short_version
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
......@@ -73,7 +73,7 @@ class bdist_wininst (Command):
("distribution contains extensions and/or C libraries; "
"must be compiled on a Windows 32 platform")
self.run_command ('build')
self.run_command('build')
install = self.reinitialize_command('install')
install.root = self.bdist_dir
......@@ -91,7 +91,7 @@ class bdist_wininst (Command):
install_lib.ensure_finalized()
self.announce ("installing to %s" % self.bdist_dir)
self.announce("installing to %s" % self.bdist_dir)
install.ensure_finalized()
install.run()
......@@ -103,24 +103,24 @@ class bdist_wininst (Command):
# Our archive MUST be relative to sys.prefix, which is the
# same as install_purelib in the 'nt' scheme.
root_dir = os.path.normpath (install.install_purelib)
root_dir = os.path.normpath(install.install_purelib)
# Sanity check: Make sure everything is included
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
attrname = 'install_' + key
install_x = getattr (install, attrname)
install_x = getattr(install, attrname)
# (Use normpath so that we can string.find to look for
# subdirectories)
install_x = os.path.normpath (install_x)
if string.find (install_x, root_dir) != 0:
install_x = os.path.normpath(install_x)
if string.find(install_x, root_dir) != 0:
raise DistutilsInternalError \
("'%s' not included in install_lib" % key)
arcname = self.make_archive (archive_basename, "zip",
root_dir=root_dir)
self.create_exe (arcname, fullname)
arcname = self.make_archive(archive_basename, "zip",
root_dir=root_dir)
self.create_exe(arcname, fullname)
if not self.keep_temp:
remove_tree (self.bdist_dir, self.verbose, self.dry_run)
remove_tree(self.bdist_dir, self.verbose, self.dry_run)
# run()
......@@ -133,37 +133,37 @@ class bdist_wininst (Command):
# Write the [metadata] section. Values are written with
# repr()[1:-1], so they do not contain unprintable characters, and
# are not surrounded by quote chars.
lines.append ("[metadata]")
lines.append("[metadata]")
# 'info' will be displayed in the installer's dialog box,
# describing the items to be installed.
info = (metadata.long_description or '') + '\n'
for name in dir (metadata):
for name in dir(metadata):
if (name != 'long_description'):
data = getattr (metadata, name)
data = getattr(metadata, name)
if data:
info = info + ("\n %s: %s" % \
(string.capitalize (name), data))
lines.append ("%s=%s" % (name, repr (data)[1:-1]))
(string.capitalize(name), data))
lines.append("%s=%s" % (name, repr(data)[1:-1]))
# The [setup] section contains entries controlling
# the installer runtime.
lines.append ("\n[Setup]")
lines.append ("info=%s" % repr (info)[1:-1])
lines.append ("target_compile=%d" % (not self.no_target_compile))
lines.append ("target_optimize=%d" % (not self.no_target_optimize))
lines.append("\n[Setup]")
lines.append("info=%s" % repr(info)[1:-1])
lines.append("target_compile=%d" % (not self.no_target_compile))
lines.append("target_optimize=%d" % (not self.no_target_optimize))
if self.target_version:
lines.append ("target_version=%s" % self.target_version)
lines.append("target_version=%s" % self.target_version)
title = self.distribution.get_fullname()
lines.append ("title=%s" % repr (title)[1:-1])
lines.append("title=%s" % repr(title)[1:-1])
import time
import distutils
build_info = "Build %s with distutils-%s" % \
(time.ctime (time.time()), distutils.__version__)
lines.append ("build_info=%s" % build_info)
return string.join (lines, "\n")
(time.ctime(time.time()), distutils.__version__)
lines.append("build_info=%s" % build_info)
return string.join(lines, "\n")
# get_inidata()
......@@ -183,36 +183,36 @@ class bdist_wininst (Command):
else:
installer_name = os.path.join(self.dist_dir,
"%s.win32.exe" % fullname)
self.announce ("creating %s" % installer_name)
self.announce("creating %s" % installer_name)
file = open (installer_name, "wb")
file.write (self.get_exe_bytes ())
file.write (cfgdata)
header = struct.pack ("<ii",
0x12345679, # tag
len (cfgdata)) # length
file.write (header)
file.write (open (arcname, "rb").read())
file = open(installer_name, "wb")
file.write(self.get_exe_bytes())
file.write(cfgdata)
header = struct.pack("<ii",
0x12345679, # tag
len(cfgdata)) # length
file.write(header)
file.write(open(arcname, "rb").read())
# create_exe()
def get_exe_bytes (self):
import base64
return base64.decodestring (EXEDATA)
return base64.decodestring(EXEDATA)
# class bdist_wininst
if __name__ == '__main__':
# recreate EXEDATA from wininst.exe by rewriting this file
import re, base64
moddata = open ("bdist_wininst.py", "r").read()
exedata = open ("../../misc/wininst.exe", "rb").read()
print "wininst.exe length is %d bytes" % len (exedata)
print "wininst.exe encoded length is %d bytes" % len (base64.encodestring (exedata))
exp = re.compile ('EXE'+'DATA = """\\\\(\n.*)*\n"""', re.M)
data = exp.sub ('EXE' + 'DATA = """\\\\\n%s"""' %
base64.encodestring (exedata), moddata)
open ("bdist_wininst.py", "w").write (data)
moddata = open("bdist_wininst.py", "r").read()
exedata = open("../../misc/wininst.exe", "rb").read()
print "wininst.exe length is %d bytes" % len(exedata)
print "wininst.exe encoded length is %d bytes" % len(base64.encodestring(exedata))
exp = re.compile('EXE'+'DATA = """\\\\(\n.*)*\n"""', re.M)
data = exp.sub('EXE' + 'DATA = """\\\\\n%s"""' %
base64.encodestring(exedata), moddata)
open("bdist_wininst.py", "w").write(data)
print "bdist_wininst.py recreated"
EXEDATA = """\
......
......@@ -70,10 +70,10 @@ class build (Command):
# 'lib.<plat>' under the base build directory. We only use one of
# them for a given distribution, though --
if self.build_purelib is None:
self.build_purelib = os.path.join (self.build_base, 'lib')
self.build_purelib = os.path.join(self.build_base, 'lib')
if self.build_platlib is None:
self.build_platlib = os.path.join (self.build_base,
'lib' + plat_specifier)
self.build_platlib = os.path.join(self.build_base,
'lib' + plat_specifier)
# 'build_lib' is the actual directory that we will use for this
# particular module distribution -- if user didn't supply it, pick
......@@ -87,10 +87,10 @@ class build (Command):
# 'build_temp' -- temporary directory for compiler turds,
# "build/temp.<plat>"
if self.build_temp is None:
self.build_temp = os.path.join (self.build_base,
'temp' + plat_specifier)
self.build_temp = os.path.join(self.build_base,
'temp' + plat_specifier)
if self.build_scripts is None:
self.build_scripts = os.path.join (self.build_base, 'scripts')
self.build_scripts = os.path.join(self.build_base, 'scripts')
# finalize_options ()
......
......@@ -80,22 +80,22 @@ class build_clib (Command):
# I think that C libraries are really just temporary build
# by-products, at least from the point of view of building Python
# extensions -- but I want to keep my options open.
self.set_undefined_options ('build',
('build_temp', 'build_clib'),
('build_temp', 'build_temp'),
('compiler', 'compiler'),
('debug', 'debug'),
('force', 'force'))
self.set_undefined_options('build',
('build_temp', 'build_clib'),
('build_temp', 'build_temp'),
('compiler', 'compiler'),
('debug', 'debug'),
('force', 'force'))
self.libraries = self.distribution.libraries
if self.libraries:
self.check_library_list (self.libraries)
self.check_library_list(self.libraries)
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)
if type(self.include_dirs) is StringType:
self.include_dirs = string.split(self.include_dirs,
os.pathsep)
# XXX same as for build_ext -- what about 'self.define' and
# 'self.undef' ?
......@@ -110,23 +110,23 @@ class build_clib (Command):
# Yech -- this is cut 'n pasted from build_ext.py!
from distutils.ccompiler import new_compiler
self.compiler = new_compiler (compiler=self.compiler,
verbose=self.verbose,
dry_run=self.dry_run,
force=self.force)
self.compiler = new_compiler(compiler=self.compiler,
verbose=self.verbose,
dry_run=self.dry_run,
force=self.force)
customize_compiler(self.compiler)
if self.include_dirs is not None:
self.compiler.set_include_dirs (self.include_dirs)
self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None:
# 'define' option is a list of (name,value) tuples
for (name,value) in self.define:
self.compiler.define_macro (name, value)
self.compiler.define_macro(name, value)
if self.undef is not None:
for macro in self.undef:
self.compiler.undefine_macro (macro)
self.compiler.undefine_macro(macro)
self.build_libraries (self.libraries)
self.build_libraries(self.libraries)
# run()
......@@ -141,16 +141,16 @@ class build_clib (Command):
# Yechh, blecch, ackk: this is ripped straight out of build_ext.py,
# with only names changed to protect the innocent!
if type (libraries) is not ListType:
if type(libraries) is not ListType:
raise DistutilsSetupError, \
"'libraries' option must be a list of tuples"
for lib in libraries:
if type (lib) is not TupleType and len (lib) != 2:
if type(lib) is not TupleType and len(lib) != 2:
raise DistutilsSetupError, \
"each element of 'libraries' must a 2-tuple"
if type (lib[0]) is not StringType:
if type(lib[0]) is not StringType:
raise DistutilsSetupError, \
"first element of each tuple in 'libraries' " + \
"must be a string (the library name)"
......@@ -160,7 +160,7 @@ class build_clib (Command):
"may not contain directory separators") % \
lib[0]
if type (lib[1]) is not DictionaryType:
if type(lib[1]) is not DictionaryType:
raise DistutilsSetupError, \
"second element of each tuple in 'libraries' " + \
"must be a dictionary (build info)"
......@@ -178,7 +178,7 @@ class build_clib (Command):
lib_names = []
for (lib_name, build_info) in self.libraries:
lib_names.append (lib_name)
lib_names.append(lib_name)
return lib_names
# get_library_names ()
......@@ -189,33 +189,33 @@ class build_clib (Command):
compiler = self.compiler
for (lib_name, build_info) in libraries:
sources = build_info.get ('sources')
if sources is None or type (sources) not in (ListType, TupleType):
sources = build_info.get('sources')
if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, \
("in 'libraries' option (library '%s'), " +
"'sources' must be present and must be " +
"a list of source filenames") % lib_name
sources = list (sources)
sources = list(sources)
self.announce ("building '%s' library" % lib_name)
self.announce("building '%s' library" % lib_name)
# First, compile the source code to object files in the library
# directory. (This should probably change to putting object
# files in a temporary build directory.)
macros = build_info.get ('macros')
include_dirs = build_info.get ('include_dirs')
objects = self.compiler.compile (sources,
output_dir=self.build_temp,
macros=macros,
include_dirs=include_dirs,
debug=self.debug)
macros = build_info.get('macros')
include_dirs = build_info.get('include_dirs')
objects = self.compiler.compile(sources,
output_dir=self.build_temp,
macros=macros,
include_dirs=include_dirs,
debug=self.debug)
# Now "link" the object files together into a static library.
# (On Unix at least, this isn't really linking -- it just
# builds an archive. Whatever.)
self.compiler.create_static_lib (objects, lib_name,
output_dir=self.build_clib,
debug=self.debug)
self.compiler.create_static_lib(objects, lib_name,
output_dir=self.build_clib,
debug=self.debug)
# for libraries
......
......@@ -32,9 +32,9 @@ class build_scripts (Command):
self.outfiles = None
def finalize_options (self):
self.set_undefined_options ('build',
('build_scripts', 'build_dir'),
('force', 'force'))
self.set_undefined_options('build',
('build_scripts', 'build_dir'),
('force', 'force'))
self.scripts = self.distribution.scripts
......
......@@ -50,29 +50,29 @@ class clean (Command):
def run(self):
# remove the build/temp.<plat> directory (unless it's already
# gone)
if os.path.exists (self.build_temp):
remove_tree (self.build_temp, self.verbose, self.dry_run)
if os.path.exists(self.build_temp):
remove_tree(self.build_temp, self.verbose, self.dry_run)
else:
self.warn ("'%s' does not exist -- can't clean it" %
self.build_temp)
self.warn("'%s' does not exist -- can't clean it" %
self.build_temp)
if self.all:
# remove build directories
for directory in (self.build_lib,
self.bdist_base,
self.build_scripts):
if os.path.exists (directory):
remove_tree (directory, self.verbose, self.dry_run)
if os.path.exists(directory):
remove_tree(directory, self.verbose, self.dry_run)
else:
self.warn ("'%s' does not exist -- can't clean it" %
directory)
self.warn("'%s' does not exist -- can't clean it" %
directory)
# just for the heck of it, try to remove the base build directory:
# we might have emptied it right now, but if not we don't care
if not self.dry_run:
try:
os.rmdir (self.build_base)
self.announce ("removing '%s'" % self.build_base)
os.rmdir(self.build_base)
self.announce("removing '%s'" % self.build_base)
except OSError:
pass
......
......@@ -87,10 +87,10 @@ class config (Command):
# import.
from distutils.ccompiler import CCompiler, new_compiler
if not isinstance(self.compiler, CCompiler):
self.compiler = new_compiler (compiler=self.compiler,
verbose=self.noisy,
dry_run=self.dry_run,
force=1)
self.compiler = new_compiler(compiler=self.compiler,
verbose=self.noisy,
dry_run=self.dry_run,
force=1)
if self.include_dirs:
self.compiler.set_include_dirs(self.include_dirs)
if self.libraries:
......
......@@ -33,11 +33,11 @@ class install_scripts (Command):
def finalize_options (self):
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
self.set_undefined_options ('install',
('install_scripts', 'install_dir'),
('force', 'force'),
('skip_build', 'skip_build'),
)
self.set_undefined_options('install',
('install_scripts', 'install_dir'),
('force', 'force'),
('skip_build', 'skip_build'),
)
def run (self):
if not self.skip_build:
......
......@@ -118,7 +118,7 @@ class sdist (Command):
"don't know how to create source distributions " + \
"on platform %s" % os.name
bad_format = archive_util.check_archive_formats (self.formats)
bad_format = archive_util.check_archive_formats(self.formats)
if bad_format:
raise DistutilsOptionError, \
"unknown archive format '%s'" % bad_format
......@@ -135,12 +135,12 @@ class sdist (Command):
# Ensure that all required meta-data is given; warn if not (but
# don't die, it's not *that* serious!)
self.check_metadata ()
self.check_metadata()
# Do whatever it takes to get the list of files to process
# (process the manifest template, read an existing manifest,
# whatever). File list is accumulated in 'self.filelist'.
self.get_file_list ()
self.get_file_list()
# If user just wanted us to regenerate the manifest, stop now.
if self.manifest_only:
......@@ -148,7 +148,7 @@ class sdist (Command):
# Otherwise, go ahead and create the source distribution tarball,
# or zipfile, or whatever.
self.make_distribution ()
self.make_distribution()
def check_metadata (self):
......@@ -161,25 +161,25 @@ class sdist (Command):
missing = []
for attr in ('name', 'version', 'url'):
if not (hasattr (metadata, attr) and getattr (metadata, attr)):
missing.append (attr)
if not (hasattr(metadata, attr) and getattr(metadata, attr)):
missing.append(attr)
if missing:
self.warn ("missing required meta-data: " +
string.join (missing, ", "))
self.warn("missing required meta-data: " +
string.join(missing, ", "))
if metadata.author:
if not metadata.author_email:
self.warn ("missing meta-data: if 'author' supplied, " +
"'author_email' must be supplied too")
self.warn("missing meta-data: if 'author' supplied, " +
"'author_email' must be supplied too")
elif metadata.maintainer:
if not metadata.maintainer_email:
self.warn ("missing meta-data: if 'maintainer' supplied, " +
"'maintainer_email' must be supplied too")
self.warn("missing meta-data: if 'maintainer' supplied, " +
"'maintainer_email' must be supplied too")
else:
self.warn ("missing meta-data: either (author and author_email) " +
"or (maintainer and maintainer_email) " +
"must be supplied")
self.warn("missing meta-data: either (author and author_email) " +
"or (maintainer and maintainer_email) " +
"must be supplied")
# check_metadata ()
......@@ -282,41 +282,41 @@ class sdist (Command):
standards = [('README', 'README.txt'), self.distribution.script_name]
for fn in standards:
if type (fn) is TupleType:
if type(fn) is TupleType:
alts = fn
got_it = 0
for fn in alts:
if os.path.exists (fn):
if os.path.exists(fn):
got_it = 1
self.filelist.append (fn)
self.filelist.append(fn)
break
if not got_it:
self.warn ("standard file not found: should have one of " +
string.join (alts, ', '))
self.warn("standard file not found: should have one of " +
string.join(alts, ', '))
else:
if os.path.exists (fn):
self.filelist.append (fn)
if os.path.exists(fn):
self.filelist.append(fn)
else:
self.warn ("standard file '%s' not found" % fn)
self.warn("standard file '%s' not found" % fn)
optional = ['test/test*.py', 'setup.cfg']
for pattern in optional:
files = filter (os.path.isfile, glob (pattern))
files = filter(os.path.isfile, glob(pattern))
if files:
self.filelist.extend (files)
self.filelist.extend(files)
if self.distribution.has_pure_modules():
build_py = self.get_finalized_command ('build_py')
self.filelist.extend (build_py.get_source_files ())
build_py = self.get_finalized_command('build_py')
self.filelist.extend(build_py.get_source_files())
if self.distribution.has_ext_modules():
build_ext = self.get_finalized_command ('build_ext')
self.filelist.extend (build_ext.get_source_files ())
build_ext = self.get_finalized_command('build_ext')
self.filelist.extend(build_ext.get_source_files())
if self.distribution.has_c_libraries():
build_clib = self.get_finalized_command ('build_clib')
self.filelist.extend (build_clib.get_source_files ())
build_clib = self.get_finalized_command('build_clib')
self.filelist.extend(build_clib.get_source_files())
# add_defaults ()
......@@ -329,13 +329,13 @@ class sdist (Command):
accordingly.
"""
self.announce("reading manifest template '%s'" % self.template)
template = TextFile (self.template,
strip_comments=1,
skip_blanks=1,
join_lines=1,
lstrip_ws=1,
rstrip_ws=1,
collapse_join=1)
template = TextFile(self.template,
strip_comments=1,
skip_blanks=1,
join_lines=1,
lstrip_ws=1,
rstrip_ws=1,
collapse_join=1)
while 1:
line = template.readline()
......@@ -386,14 +386,14 @@ class sdist (Command):
distribution.
"""
self.announce("reading manifest file '%s'" % self.manifest)
manifest = open (self.manifest)
manifest = open(self.manifest)
while 1:
line = manifest.readline ()
line = manifest.readline()
if line == '': # end of file
break
if line[-1] == '\n':
line = line[0:-1]
self.filelist.append (line)
self.filelist.append(line)
# read_manifest ()
......@@ -421,7 +421,7 @@ class sdist (Command):
# out-of-date, because by default we blow away 'base_dir' when
# we're done making the distribution archives.)
if hasattr (os, 'link'): # can make hard links on this system
if hasattr(os, 'link'): # can make hard links on this system
link = 'hard'
msg = "making hard links in %s..." % base_dir
else: # nope, have to copy
......@@ -431,13 +431,13 @@ class sdist (Command):
if not files:
self.warn("no files to distribute -- empty manifest?")
else:
self.announce (msg)
self.announce(msg)
for file in files:
if not os.path.isfile(file):
self.warn("'%s' not a regular file -- skipping" % file)
else:
dest = os.path.join (base_dir, file)
self.copy_file (file, dest, link=link)
dest = os.path.join(base_dir, file)
self.copy_file(file, dest, link=link)
# make_release_tree ()
......@@ -455,16 +455,16 @@ class sdist (Command):
base_dir = self.distribution.get_fullname()
base_name = os.path.join(self.dist_dir, base_dir)
self.make_release_tree (base_dir, self.filelist.files)
self.make_release_tree(base_dir, self.filelist.files)
archive_files = [] # remember names of files we create
for fmt in self.formats:
file = self.make_archive (base_name, fmt, base_dir=base_dir)
file = self.make_archive(base_name, fmt, base_dir=base_dir)
archive_files.append(file)
self.archive_files = archive_files
if not self.keep_temp:
dir_util.remove_tree (base_dir, self.verbose, self.dry_run)
dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
def get_archive_files (self):
"""Return the list of archive files created when the command
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment