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