Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca4289f

Browse files
committed
Reformat docstrings.
Standardize whitespace in function calls.
1 parent 071ed76 commit ca4289f

2 files changed

Lines changed: 63 additions & 64 deletions

File tree

Lib/distutils/archive_util.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
def make_tarball (base_name, base_dir, compress="gzip",
1616
verbose=0, dry_run=0):
1717
"""Create a (possibly compressed) tar file from all the files under
18-
'base_dir'. 'compress' must be "gzip" (the default), "compress",
19-
"bzip2", or None. Both "tar" and the compression utility named by
20-
'compress' must be on the default program search path, so this is
21-
probably Unix-specific. The output tar file will be named 'base_dir'
22-
+ ".tar", possibly plus the appropriate compression extension (".gz",
23-
".bz2" or ".Z"). Return the output filename."""
24-
18+
'base_dir'. 'compress' must be "gzip" (the default), "compress",
19+
"bzip2", or None. Both "tar" and the compression utility named by
20+
'compress' must be on the default program search path, so this is
21+
probably Unix-specific. The output tar file will be named 'base_dir' +
22+
".tar", possibly plus the appropriate compression extension (".gz",
23+
".bz2" or ".Z"). Return the output filename.
24+
"""
2525
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
2626
# It's pretty new, though, so we certainly can't require it --
2727
# but it would be nice to take advantage of it to skip the
@@ -44,11 +44,11 @@ def make_tarball (base_name, base_dir, compress="gzip",
4444
archive_name = base_name + ".tar"
4545
mkpath(os.path.dirname(archive_name), verbose=verbose, dry_run=dry_run)
4646
cmd = ["tar", "-cf", archive_name, base_dir]
47-
spawn (cmd, verbose=verbose, dry_run=dry_run)
47+
spawn(cmd, verbose=verbose, dry_run=dry_run)
4848

4949
if compress:
50-
spawn ([compress] + compress_flags[compress] + [archive_name],
51-
verbose=verbose, dry_run=dry_run)
50+
spawn([compress] + compress_flags[compress] + [archive_name],
51+
verbose=verbose, dry_run=dry_run)
5252
return archive_name + compress_ext[compress]
5353
else:
5454
return archive_name
@@ -57,22 +57,22 @@ def make_tarball (base_name, base_dir, compress="gzip",
5757

5858

5959
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
60-
"""Create a zip file from all the files under 'base_dir'. The
61-
output zip file will be named 'base_dir' + ".zip". Uses either the
62-
InfoZIP "zip" utility (if installed and found on the default search
63-
path) or the "zipfile" Python module (if available). If neither
64-
tool is available, raises DistutilsExecError. Returns the name
65-
of the output zip file."""
66-
60+
"""Create a zip file from all the files under 'base_dir'. The output
61+
zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP
62+
"zip" utility (if installed and found on the default search path) or
63+
the "zipfile" Python module (if available). If neither tool is
64+
available, raises DistutilsExecError. Returns the name of the output
65+
zip file.
66+
"""
6767
# This initially assumed the Unix 'zip' utility -- but
6868
# apparently InfoZIP's zip.exe works the same under Windows, so
6969
# no changes needed!
7070

7171
zip_filename = base_name + ".zip"
7272
mkpath(os.path.dirname(zip_filename), verbose=verbose, dry_run=dry_run)
7373
try:
74-
spawn (["zip", "-rq", zip_filename, base_dir],
75-
verbose=verbose, dry_run=dry_run)
74+
spawn(["zip", "-rq", zip_filename, base_dir],
75+
verbose=verbose, dry_run=dry_run)
7676
except DistutilsExecError:
7777

7878
# XXX really should distinguish between "couldn't find
@@ -96,14 +96,14 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
9696
def visit (z, dirname, names):
9797
for name in names:
9898
path = os.path.normpath(os.path.join(dirname, name))
99-
if os.path.isfile (path):
100-
z.write (path, path)
99+
if os.path.isfile(path):
100+
z.write(path, path)
101101

102102
if not dry_run:
103-
z = zipfile.ZipFile (zip_filename, "wb",
104-
compression=zipfile.ZIP_DEFLATED)
103+
z = zipfile.ZipFile(zip_filename, "wb",
104+
compression=zipfile.ZIP_DEFLATED)
105105

106-
os.path.walk (base_dir, visit, z)
106+
os.path.walk(base_dir, visit, z)
107107
z.close()
108108

109109
return zip_filename
@@ -143,9 +143,9 @@ def make_archive (base_name, format,
143143
if root_dir is not None:
144144
if verbose:
145145
print "changing into '%s'" % root_dir
146-
base_name = os.path.abspath (base_name)
146+
base_name = os.path.abspath(base_name)
147147
if not dry_run:
148-
os.chdir (root_dir)
148+
os.chdir(root_dir)
149149

150150
if base_dir is None:
151151
base_dir = os.curdir
@@ -161,12 +161,12 @@ def make_archive (base_name, format,
161161
func = format_info[0]
162162
for (arg,val) in format_info[1]:
163163
kwargs[arg] = val
164-
filename = apply (func, (base_name, base_dir), kwargs)
164+
filename = apply(func, (base_name, base_dir), kwargs)
165165

166166
if root_dir is not None:
167167
if verbose:
168168
print "changing back to '%s'" % save_cwd
169-
os.chdir (save_cwd)
169+
os.chdir(save_cwd)
170170

171171
return filename
172172

Lib/distutils/dep_util.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
def newer (source, target):
1616
"""Return true if 'source' exists and is more recently modified than
17-
'target', or if 'source' exists and 'target' doesn't. Return
18-
false if both exist and 'target' is the same age or younger than
19-
'source'. Raise DistutilsFileError if 'source' does not
20-
exist."""
21-
22-
if not os.path.exists (source):
17+
'target', or if 'source' exists and 'target' doesn't. Return false if
18+
both exist and 'target' is the same age or younger than 'source'.
19+
Raise DistutilsFileError if 'source' does not exist.
20+
"""
21+
if not os.path.exists(source):
2322
raise DistutilsFileError, "file '%s' does not exist" % source
24-
if not os.path.exists (target):
23+
if not os.path.exists(target):
2524
return 1
2625

2726
from stat import ST_MTIME
@@ -35,51 +34,51 @@ def newer (source, target):
3534

3635
def newer_pairwise (sources, targets):
3736
"""Walk two filename lists in parallel, testing if each source is newer
38-
than its corresponding target. Return a pair of lists (sources,
39-
targets) where source is newer than target, according to the
40-
semantics of 'newer()'."""
41-
42-
if len (sources) != len (targets):
37+
than its corresponding target. Return a pair of lists (sources,
38+
targets) where source is newer than target, according to the semantics
39+
of 'newer()'.
40+
"""
41+
if len(sources) != len(targets):
4342
raise ValueError, "'sources' and 'targets' must be same length"
4443

4544
# build a pair of lists (sources, targets) where source is newer
4645
n_sources = []
4746
n_targets = []
48-
for i in range (len (sources)):
49-
if newer (sources[i], targets[i]):
50-
n_sources.append (sources[i])
51-
n_targets.append (targets[i])
47+
for i in range(len(sources)):
48+
if newer(sources[i], targets[i]):
49+
n_sources.append(sources[i])
50+
n_targets.append(targets[i])
5251

5352
return (n_sources, n_targets)
5453

5554
# newer_pairwise ()
5655

5756

5857
def newer_group (sources, target, missing='error'):
59-
"""Return true if 'target' is out-of-date with respect to any
60-
file listed in 'sources'. In other words, if 'target' exists and
61-
is newer than every file in 'sources', return false; otherwise
62-
return true. 'missing' controls what we do when a source file is
63-
missing; the default ("error") is to blow up with an OSError from
64-
inside 'stat()'; if it is "ignore", we silently drop any missing
65-
source files; if it is "newer", any missing source files make us
66-
assume that 'target' is out-of-date (this is handy in "dry-run"
67-
mode: it'll make you pretend to carry out commands that wouldn't
68-
work because inputs are missing, but that doesn't matter because
69-
you're not actually going to run the commands)."""
70-
58+
"""Return true if 'target' is out-of-date with respect to any file
59+
listed in 'sources'. In other words, if 'target' exists and is newer
60+
than every file in 'sources', return false; otherwise return true.
61+
'missing' controls what we do when a source file is missing; the
62+
default ("error") is to blow up with an OSError from inside 'stat()';
63+
if it is "ignore", we silently drop any missing source files; if it is
64+
"newer", any missing source files make us assume that 'target' is
65+
out-of-date (this is handy in "dry-run" mode: it'll make you pretend to
66+
carry out commands that wouldn't work because inputs are missing, but
67+
that doesn't matter because you're not actually going to run the
68+
commands).
69+
"""
7170
# If the target doesn't even exist, then it's definitely out-of-date.
72-
if not os.path.exists (target):
71+
if not os.path.exists(target):
7372
return 1
7473

7574
# Otherwise we have to find out the hard way: if *any* source file
7675
# is more recent than 'target', then 'target' is out-of-date and
7776
# we can immediately return true. If we fall through to the end
7877
# of the loop, then 'target' is up-to-date and we return false.
7978
from stat import ST_MTIME
80-
target_mtime = os.stat (target)[ST_MTIME]
79+
target_mtime = os.stat(target)[ST_MTIME]
8180
for source in sources:
82-
if not os.path.exists (source):
81+
if not os.path.exists(source):
8382
if missing == 'error': # blow up when we stat() the file
8483
pass
8584
elif missing == 'ignore': # missing source dropped from
@@ -102,13 +101,13 @@ def newer_group (sources, target, missing='error'):
102101
def make_file (src, dst, func, args,
103102
verbose=0, update_message=None, noupdate_message=None):
104103
"""Makes 'dst' from 'src' (both filenames) by calling 'func' with
105-
'args', but only if it needs to: i.e. if 'dst' does not exist or
106-
'src' is newer than 'dst'."""
107-
108-
if newer (src, dst):
104+
'args', but only if it needs to: i.e. if 'dst' does not exist or 'src'
105+
is newer than 'dst'.
106+
"""
107+
if newer(src, dst):
109108
if verbose and update_message:
110109
print update_message
111-
apply (func, args)
110+
apply(func, args)
112111
else:
113112
if verbose and noupdate_message:
114113
print noupdate_message

0 commit comments

Comments
 (0)