Removed global '--force' option -- just too vague a concept to be applicable

to all commands in the same way.  Several Command methods now either expect
'self.force' to be defined, or check if it is defined and assume it's
false if not.
This commit is contained in:
Greg Ward 2000-04-10 00:18:16 +00:00
parent 582a8701cb
commit 68a0757e23
2 changed files with 14 additions and 13 deletions

View File

@ -58,7 +58,6 @@ class Command:
# (etc.) will be handled by __getattr__, below. # (etc.) will be handled by __getattr__, below.
self._verbose = None self._verbose = None
self._dry_run = None self._dry_run = None
self._force = None
# The 'help' flag is just used for command-line parsing, so # The 'help' flag is just used for command-line parsing, so
# none of that complicated bureaucracy is needed. # none of that complicated bureaucracy is needed.
@ -74,7 +73,7 @@ class Command:
def __getattr__ (self, attr): def __getattr__ (self, attr):
if attr in ('verbose', 'dry_run', 'force'): if attr in ('verbose', 'dry_run'):
myval = getattr (self, "_" + attr) myval = getattr (self, "_" + attr)
if myval is None: if myval is None:
return getattr (self.distribution, attr) return getattr (self.distribution, attr)
@ -308,7 +307,8 @@ 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.""" """Copy a file respecting verbose, dry-run and force flags (this
should only be used by commands that define 'self.force'!)."""
return util.copy_file (infile, outfile, return util.copy_file (infile, outfile,
preserve_mode, preserve_times, preserve_mode, preserve_times,
@ -322,7 +322,8 @@ 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.""" and force flags (again, should only be used by commands
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,
@ -352,13 +353,15 @@ class Command:
def make_file (self, infiles, outfile, func, args, def make_file (self, infiles, outfile, func, args,
exec_msg=None, skip_msg=None, level=1): exec_msg=None, skip_msg=None, level=1):
"""Special case of 'execute()' for operations that process one or """Special case of 'execute()' for operations that process one or
more input files and generate one output file. Works just like more input files and generate one output file. Works just like
'execute()', except the operation is skipped and a different 'execute()', except the operation is skipped and a different
message printed if 'outfile' already exists and is newer than message printed if 'outfile' already exists and is newer than all
all files listed in 'infiles'.""" files listed in 'infiles'. If the command defined 'self.force',
and it is true, then the command is unconditionally run -- does no
timestamp checks."""
if exec_msg is None: if exec_msg is None:
@ -378,7 +381,8 @@ 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 self.force or util.newer_group (infiles, outfile): if ((hasattr(self,'force') and self.force) or
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

View File

@ -52,8 +52,6 @@ class Distribution:
"run quietly (turns verbosity off)"), "run quietly (turns verbosity off)"),
('dry-run', 'n', ('dry-run', 'n',
"don't actually do anything"), "don't actually do anything"),
('force', 'f',
"skip dependency checking between files"),
('help', 'h', ('help', 'h',
"show this help message"), "show this help message"),
] ]
@ -76,7 +74,6 @@ class Distribution:
# Default values for our command-line options # Default values for our command-line options
self.verbose = 1 self.verbose = 1
self.dry_run = 0 self.dry_run = 0
self.force = 0
self.help = 0 self.help = 0
self.help_commands = 0 self.help_commands = 0