What does the list_folders() method of mailbox.Maildir actually ?do (if anything)?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Fri Sep 25 22:13:51 CEST 2009


Jeff McNeil <jeff at jmcneil.net> wrote:
> On Sep 25, 3:22 pm, tinn... at isbd.co.uk wrote:
> > I can't get the list_folders() method of the mailbox.Maildir class to
> > do anything remotely useful.  It seems to do nothing at all.  I have a
> > directory which contains a number of maildir malboxes:-
> >
> >     chris$ ls -l /home/chris/Mail/apex
> >     total 24
> >     drwx------ 5 chris chris 4096 2009-04-30 09:45 charles.rustin
> >     drwx------ 5 chris chris 4096 2009-04-30 09:45 greg
> >     drwx------ 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
> >     drwx------ 5 chris chris 4096 2009-04-30 09:45 ram
> >     drwx------ 5 chris chris 4096 2009-04-30 09:46 sarahLagley
> >     drwx------ 5 chris chris 4096 2009-04-30 09:46 symonSmith
> >     chris$ ls -l /home/chris/Mail/apex/ram
> >     total 12
> >     drwx------ 2 chris chris 4096 2009-04-30 09:45 cur
> >     drwx------ 2 chris chris 4096 2009-04-30 09:45 new
> >     drwx------ 2 chris chris 4096 2009-04-30 09:45 tmp
> >
> > If I run the following code:-
> >
> >     #!/usr/bin/python
> >     #
> >     #
> >     # Mail archiving utility
> >     #
> >     import mailbox
> >
> >     topLevel=mailbox.Maildir("/home/chris/Mail/apex")
> >     print topLevel.list_folders()
> >
> > It just outputs "[]".
> >
> > Am I doing something totally wrong or is list_folders() completely broken?
> >
> > --
> > Chris Green
> 
> The Maildir++ spec states that folders need to begin with a period.
> The list_folders method enforces that:
> 
>     def list_folders(self):
>         """Return a list of folder names."""
>         result = []
>         for entry in os.listdir(self._path):
>             if len(entry) > 1 and entry[0] == '.' and \
>                os.path.isdir(os.path.join(self._path, entry)):
>                 result.append(entry[1:])
>         return result
> 
> The above example is from 2.6.  Your structure is simply a list of
> Maildir compliant directories below '/home/chris/Mail/apex.' They're
> not, in the Maildir++ sense of the word, folders.
> 
So where does it say in the Python documentation that list_folders()
works only with Maildir++?  It's a big and non-obvious limitation to
my mind.

My maildir hierarchy is created by mutt which is a *very* standards
compliant MUA, surely standard python libraries should work with
standard maildirs not some wierd extension thereof.

-- 
Chris Green




More information about the Python-list mailing list