MCPcopy Index your code
hub / github.com/RustPython/RustPython / remove_folder

Method remove_folder

Lib/mailbox.py:511–528  ·  view source on GitHub ↗

Delete the named folder, which must be empty.

(self, folder)

Source from the content-addressed store, hash-verified

509 return result
510
511 def remove_folder(self, folder):
512 """Delete the named folder, which must be empty."""
513 path = os.path.join(self._path, '.' + folder)
514 for entry in os.listdir(os.path.join(path, 'new')) + \
515 os.listdir(os.path.join(path, 'cur')):
516 if len(entry) < 1 or entry[0] != '.':
517 raise NotEmptyError('Folder contains message(s): %s' % folder)
518 for entry in os.listdir(path):
519 if entry != 'new' and entry != 'cur' and entry != 'tmp' and \
520 os.path.isdir(os.path.join(path, entry)):
521 raise NotEmptyError("Folder contains subdirectory '%s': %s" %
522 (folder, entry))
523 for root, dirs, files in os.walk(path, topdown=False):
524 for entry in files:
525 os.remove(os.path.join(root, entry))
526 for entry in dirs:
527 os.rmdir(os.path.join(root, entry))
528 os.rmdir(path)
529
530 def clean(self):
531 """Delete old files in "tmp"."""

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected