Delete the named folder, which must be empty.
(self, folder)
| 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".""" |