[issue20328] mailbox: add method to delete mailbox

Jonathan Dowland report at bugs.python.org
Tue Aug 19 22:30:11 CEST 2014


Jonathan Dowland added the comment:

Hi David, whilst writing my patch I've tried to keep an open mind as to users of the methods, but I do have my own purpose in the back of my mind, and that's an archive mail tool which I would like to delete mail folders if, after performing an archive operation, they are empty. However, the archive mail tool has no awareness or interest in sub-folders. The user would be surprised, however, if it deleted them, should they exist.

There's also the issue of lack of locks for Maildirs. If one wanted to avoid recursive deleting, how could one achieve it? consider pseudo code

if len(mbox.list_folders()) <= 0:
  # no sub-folders, safe to delete?
  mbox.delete()

There are no guarantees an external process didn't create a sub folder between the test and the delete operation.

Finally, if one has a delete() operation that doesn't operate on sub-folders, but you want to recursively delete, you can at least assemble such a method. If you have a recursively-deleting method, and you *don't* want to delete sub-folders, you're stuck.

Having said all that please let me know what you're thinking; I'll happily try to cook up a patch to add both recursive and non-recursive delete methods.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20328>
_______________________________________


More information about the Python-bugs-list mailing list