mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Added a check for the 'force' attribute in '__getattr__()' -- better than
crashing when self.force not defined. Revise 'copy_file()' and 'copy_tree()' docstrings accordingly. Remove 'hasattr()' check for 'self.force' from 'make_file()'.
This commit is contained in:
parent
d38e6f7637
commit
e9613ae05f
1 changed files with 10 additions and 6 deletions
|
@ -79,6 +79,11 @@ class Command:
|
||||||
return getattr (self.distribution, attr)
|
return getattr (self.distribution, attr)
|
||||||
else:
|
else:
|
||||||
return myval
|
return myval
|
||||||
|
|
||||||
|
# Needed because some Command methods assume 'self.force' exists,
|
||||||
|
# but not all commands define 'self.force'. Ugh.
|
||||||
|
elif attr == 'force':
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
raise AttributeError, attr
|
raise AttributeError, attr
|
||||||
|
|
||||||
|
@ -307,8 +312,9 @@ class Command:
|
||||||
|
|
||||||
def copy_file (self, infile, outfile,
|
def copy_file (self, infile, outfile,
|
||||||
preserve_mode=1, preserve_times=1, link=None, level=1):
|
preserve_mode=1, preserve_times=1, link=None, level=1):
|
||||||
"""Copy a file respecting verbose, dry-run and force flags (this
|
"""Copy a file respecting verbose, dry-run and force flags. (The
|
||||||
should only be used by commands that define 'self.force'!)."""
|
former two default to whatever is in the Distribution object, and
|
||||||
|
the latter defaults to false for commands that don't define it.)"""
|
||||||
|
|
||||||
return util.copy_file (infile, outfile,
|
return util.copy_file (infile, outfile,
|
||||||
preserve_mode, preserve_times,
|
preserve_mode, preserve_times,
|
||||||
|
@ -322,8 +328,7 @@ class Command:
|
||||||
preserve_mode=1, preserve_times=1, preserve_symlinks=0,
|
preserve_mode=1, preserve_times=1, preserve_symlinks=0,
|
||||||
level=1):
|
level=1):
|
||||||
"""Copy an entire directory tree respecting verbose, dry-run,
|
"""Copy an entire directory tree respecting verbose, dry-run,
|
||||||
and force flags (again, should only be used by commands
|
and force flags."""
|
||||||
that define 'self.force')."""
|
|
||||||
|
|
||||||
return util.copy_tree (infile, outfile,
|
return util.copy_tree (infile, outfile,
|
||||||
preserve_mode,preserve_times,preserve_symlinks,
|
preserve_mode,preserve_times,preserve_symlinks,
|
||||||
|
@ -381,8 +386,7 @@ class Command:
|
||||||
# If 'outfile' must be regenerated (either because it doesn't
|
# If 'outfile' must be regenerated (either because it doesn't
|
||||||
# exist, is out-of-date, or the 'force' flag is true) then
|
# exist, is out-of-date, or the 'force' flag is true) then
|
||||||
# perform the action that presumably regenerates it
|
# perform the action that presumably regenerates it
|
||||||
if ((hasattr(self,'force') and self.force) or
|
if self.force or util.newer_group (infiles, outfile):
|
||||||
util.newer_group (infiles, outfile)):
|
|
||||||
self.execute (func, args, exec_msg, level)
|
self.execute (func, args, exec_msg, level)
|
||||||
|
|
||||||
# Otherwise, print the "skip" message
|
# Otherwise, print the "skip" message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue