MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / remove_tree

Function remove_tree

tools/python-3.11.9-amd64/Lib/distutils/dir_util.py:178–200  ·  view source on GitHub ↗

Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).

(directory, verbose=1, dry_run=0)

Source from the content-addressed store, hash-verified

176 cmdtuples.append((os.rmdir, path))
177
178def remove_tree(directory, verbose=1, dry_run=0):
179 """Recursively remove an entire directory tree.
180
181 Any errors are ignored (apart from being reported to stdout if 'verbose'
182 is true).
183 """
184 global _path_created
185
186 if verbose >= 1:
187 log.info("removing '%s' (and everything under it)", directory)
188 if dry_run:
189 return
190 cmdtuples = []
191 _build_cmdtuple(directory, cmdtuples)
192 for cmd in cmdtuples:
193 try:
194 cmd[0](cmd[1])
195 # remove dir from cache if it's already there
196 abspath = os.path.abspath(cmd[1])
197 if abspath in _path_created:
198 del _path_created[abspath]
199 except OSError as exc:
200 log.warn("error removing %s: %s", directory, exc)
201
202def ensure_relative(path):
203 """Take the full path 'path', and make it a relative path.

Callers 6

runMethod · 0.90
runMethod · 0.90

Calls 3

_build_cmdtupleFunction · 0.70
infoMethod · 0.45
warnMethod · 0.45