From cd8a1148e19116db109f27d26c02e1de536dc76e Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Tue, 4 Jun 2002 20:14:43 +0000 Subject: Make setup.py less chatty by default. This is a conservative version of SF patch 504889. It uses the log module instead of calling print in various places, and it ignores the verbose argument passed to many functions and set as an attribute on some objects. Instead, it uses the verbosity set on the logger via the command line. The log module is now preferred over announce() and warn() methods that exist only for backwards compatibility. XXX This checkin changes a lot of modules that have no test suite and aren't exercised by the Python build process. It will need substantial testing. --- Lib/distutils/dir_util.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'Lib/distutils/dir_util.py') diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index 77007c976b0..8b3e06b2faf 100644 --- a/Lib/distutils/dir_util.py +++ b/Lib/distutils/dir_util.py @@ -9,7 +9,7 @@ __revision__ = "$Id$" import os from types import * from distutils.errors import DistutilsFileError, DistutilsInternalError - +from distutils import log # cache for by mkpath() -- in addition to cheapening redundant calls, # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode @@ -69,8 +69,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0): if _path_created.get(abs_head): continue - if verbose: - print "creating", head + log.info("creating %s", head) if not dry_run: try: @@ -105,7 +104,7 @@ def create_tree (base_dir, files, mode=0777, verbose=0, dry_run=0): # Now create them for dir in need_dirs: - mkpath(dir, mode, verbose, dry_run) + mkpath(dir, mode, dry_run=dry_run) # create_tree () @@ -151,7 +150,7 @@ def copy_tree (src, dst, "error listing files in '%s': %s" % (src, errstr) if not dry_run: - mkpath(dst, verbose=verbose) + mkpath(dst) outputs = [] @@ -161,21 +160,19 @@ def copy_tree (src, dst, if preserve_symlinks and os.path.islink(src_name): link_dest = os.readlink(src_name) - if verbose: - print "linking %s -> %s" % (dst_name, link_dest) + log.info("linking %s -> %s", dst_name, link_dest) if not dry_run: os.symlink(link_dest, dst_name) outputs.append(dst_name) elif os.path.isdir(src_name): outputs.extend( - copy_tree(src_name, dst_name, - preserve_mode, preserve_times, preserve_symlinks, - update, verbose, dry_run)) + copy_tree(src_name, dst_name, preserve_mode, + preserve_times, preserve_symlinks, update, + dry_run=dry_run)) else: - copy_file(src_name, dst_name, - preserve_mode, preserve_times, - update, None, verbose, dry_run) + copy_file(src_name, dst_name, preserve_mode, + preserve_times, update, dry_run=dry_run) outputs.append(dst_name) return outputs @@ -200,8 +197,7 @@ def remove_tree (directory, verbose=0, dry_run=0): from distutils.util import grok_environment_error global _path_created - if verbose: - print "removing '%s' (and everything under it)" % directory + log.info("removing '%s' (and everything under it)", directory) if dry_run: return cmdtuples = [] @@ -214,6 +210,5 @@ def remove_tree (directory, verbose=0, dry_run=0): if _path_created.has_key(abspath): del _path_created[abspath] except (IOError, OSError), exc: - if verbose: - print grok_environment_error( - exc, "error removing %s: " % directory) + log.warn(grok_environment_error( + exc, "error removing %s: " % directory)) -- cgit v1.2.3