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

Method remove_folder

tools/python-3.11.9-amd64/Lib/mailbox.py:461–478  ·  view source on GitHub ↗

Delete the named folder, which must be empty.

(self, folder)

Source from the content-addressed store, hash-verified

459 return result
460
461 def remove_folder(self, folder):
462 """Delete the named folder, which must be empty."""
463 path = os.path.join(self._path, '.' + folder)
464 for entry in os.listdir(os.path.join(path, 'new')) + \
465 os.listdir(os.path.join(path, 'cur')):
466 if len(entry) < 1 or entry[0] != '.':
467 raise NotEmptyError('Folder contains message(s): %s' % folder)
468 for entry in os.listdir(path):
469 if entry != 'new' and entry != 'cur' and entry != 'tmp' and \
470 os.path.isdir(os.path.join(path, entry)):
471 raise NotEmptyError("Folder contains subdirectory '%s': %s" %
472 (folder, entry))
473 for root, dirs, files in os.walk(path, topdown=False):
474 for entry in files:
475 os.remove(os.path.join(root, entry))
476 for entry in dirs:
477 os.rmdir(os.path.join(root, entry))
478 os.rmdir(path)
479
480 def clean(self):
481 """Delete old files in "tmp"."""

Callers

nothing calls this directly

Calls 6

NotEmptyErrorClass · 0.85
listdirMethod · 0.80
rmdirMethod · 0.80
joinMethod · 0.45
isdirMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected