mirror of
https://github.com/python/cpython.git
synced 2025-09-08 18:01:44 +00:00
Changed 'remove_tree()' to use the new 'grok_environment_error()' function
instead of muddling through IOError and OSError exception objects itself.
This commit is contained in:
parent
cf0e2dde6d
commit
fcd4f87397
1 changed files with 6 additions and 7 deletions
|
@ -193,9 +193,11 @@ def _build_cmdtuple(path, cmdtuples):
|
||||||
|
|
||||||
def remove_tree (directory, verbose=0, dry_run=0):
|
def remove_tree (directory, verbose=0, dry_run=0):
|
||||||
"""Recursively remove an entire directory tree. Any errors are ignored
|
"""Recursively remove an entire directory tree. Any errors are ignored
|
||||||
(apart from being reported to stdout if 'verbose' is true)."""
|
(apart from being reported to stdout if 'verbose' is true).
|
||||||
|
"""
|
||||||
|
from distutils.util import grok_environment_error
|
||||||
global PATH_CREATED
|
global PATH_CREATED
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "removing '%s' (and everything under it)" % directory
|
print "removing '%s' (and everything under it)" % directory
|
||||||
if dry_run:
|
if dry_run:
|
||||||
|
@ -210,8 +212,5 @@ def remove_tree (directory, verbose=0, dry_run=0):
|
||||||
del PATH_CREATED[cmd[1]]
|
del PATH_CREATED[cmd[1]]
|
||||||
except (IOError, OSError), exc:
|
except (IOError, OSError), exc:
|
||||||
if verbose:
|
if verbose:
|
||||||
if exc.filename:
|
print grok_environment_error(
|
||||||
print "error removing %s: %s (%s)" % \
|
exc, "error removing %s: " % directory)
|
||||||
(directory, exc.strerror, exc.filename)
|
|
||||||
else:
|
|
||||||
print "error removing %s: %s" % (directory, exc.strerror)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue