def remove_tree(directory, verbose=1, dry_run=0):
 from distutils.util import grok_environment_error
 global _path_created
 if (verbose >= 1):
  log.info("removing '%s' (and everything under it)", directory)
 if dry_run:
  return
 cmdtuples = []
 _build_cmdtuple(directory, cmdtuples)
 for cmd in cmdtuples:
  try:
   cmd[0](cmd[1])
   abspath = os.path.abspath(cmd[1])
   if (abspath in _path_created):
    del _path_created[abspath]
  except (IOError, OSError) as exc:
   log.warn(grok_environment_error(exc, ('error removing %s: ' % directory)))

def remove_tree ( directory , verbose = 1 , dry_run = 0 ) : from distutils . util import grok_environment_error global _path_created if ( verbose >= 1 ) : log . info ( "removing '%s' (and everything under it)" , directory ) if dry_run : return cmdtuples = [ ] _build_cmdtuple ( directory , cmdtuples ) for cmd in cmdtuples : try : cmd [ 0 ] ( cmd [ 1 ] ) abspath = os . path . abspath ( cmd [ 1 ] ) if ( abspath in _path_created ) : del _path_created [ abspath ] except ( IOError , OSError ) as exc : log . warn ( grok_environment_error ( exc , ( 'error removing %s: ' % directory ) ) )
recursively remove an entire directory tree .