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

Function removedirs

tools/python-3.11.9-amd64/Lib/os.py:232–252  ·  view source on GitHub ↗

removedirs(name) Super-rmdir; remove a leaf directory and all empty intermediate ones. Works like rmdir except that, if the leaf directory is successfully removed, directories corresponding to rightmost path segments will be pruned away until either the whole path is cons

(name)

Source from the content-addressed store, hash-verified

230 raise
231
232def removedirs(name):
233 """removedirs(name)
234
235 Super-rmdir; remove a leaf directory and all empty intermediate
236 ones. Works like rmdir except that, if the leaf directory is
237 successfully removed, directories corresponding to rightmost path
238 segments will be pruned away until either the whole path is
239 consumed or an error occurs. Errors during this latter phase are
240 ignored -- they generally mean that a directory was not empty.
241
242 """
243 rmdir(name)
244 head, tail = path.split(name)
245 if not tail:
246 head, tail = path.split(head)
247 while head and tail:
248 try:
249 rmdir(head)
250 except OSError:
251 break
252 head, tail = path.split(head)
253
254def renames(old, new):
255 """renames(old, new)

Callers 1

renamesFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected