summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/dir_util.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-06-04 20:14:43 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-06-04 20:14:43 (GMT)
commitcd8a1148e19116db109f27d26c02e1de536dc76e (patch)
treee3969bc16f8ef0c540f1d0e72fb0da711344d758 /Lib/distutils/dir_util.py
parent6fa82a34775576b90c8ec38e8968dfbb0b02e11d (diff)
downloadcpython-cd8a1148e19116db109f27d26c02e1de536dc76e.zip
cpython-cd8a1148e19116db109f27d26c02e1de536dc76e.tar.gz
cpython-cd8a1148e19116db109f27d26c02e1de536dc76e.tar.bz2
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.
Diffstat (limited to 'Lib/distutils/dir_util.py')
-rw-r--r--Lib/distutils/dir_util.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py
index 77007c9..8b3e06b 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))