Re: What does the list_folders() method of mailbox.Maildir actuallydo (if anything)?

Discussion in 'Python' started by Jeff McNeil, Sep 25, 2009.

  1. Jeff McNeil

    Jeff McNeil Guest

    On Sep 25, 3:22 pm, 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.

    --
    Thanks,

    Jeff
    mcjeff.blospot.com
     
    Jeff McNeil, Sep 25, 2009
    #1
    1. Advertising

  2. Jeff McNeil

    Guest

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

    Jeff McNeil <> wrote:
    > On Sep 25, 3:22 pm, 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
     
    , Sep 25, 2009
    #2
    1. Advertising

  3. Jeff McNeil

    Jeff McNeil Guest

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

    On Sep 25, 4:13 pm, wrote:
    > Jeff McNeil <> wrote:
    > > On Sep 25, 3:22 pm, 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



    The doc says that "Folders of the style introduced by the Courier mail
    transfer agent are also supported. Any subdirectory of the main
    mailbox is considered a folder if '.' is the first character in its
    name." It's not an explicit endorsement of Maildir++, but it touches
    on what it considers a folder definition. I'm treading on hazy memory
    here, but I believe Maildir++ is the definition provided by the
    Courier folks.

    --
    Thanks,

    Jeff
    mcjeff.blogspot.com
     
    Jeff McNeil, Sep 25, 2009
    #3
  4. Jeff McNeil

    Jeff McNeil Guest

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

    On Sep 25, 4:28 pm, Jeff McNeil <> wrote:
    > On Sep 25, 4:13 pm, wrote:
    >
    >
    >
    >
    >
    > > Jeff McNeil <> wrote:
    > > > On Sep 25, 3:22 pm, 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

    >
    > The doc says that "Folders of the style introduced by the Courier mail
    > transfer agent are also supported. Any subdirectory of the main
    > mailbox is considered a folder if '.' is the first character in its
    > name."  It's not an explicit endorsement of Maildir++, but it touches
    > on what it considers a folder definition. I'm treading on hazy memory
    > here, but I believe Maildir++ is the definition provided by the
    > Courier folks.
    >
    > --
    > Thanks,
    >
    > Jeff
    > mcjeff.blogspot.com


    http://wiki.mutt.org/?MuttFaq/Maildir

    That might help as well. You can have Mutt setup your folders using
    that extended method.

    --
    Thanks,

    Jeff
    mcjeff.blogspot.com
     
    Jeff McNeil, Sep 25, 2009
    #4
  5. Jeff McNeil

    Guest

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

    Jeff McNeil <> wrote:
    > > > 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

    >
    >
    > The doc says that "Folders of the style introduced by the Courier mail
    > transfer agent are also supported. Any subdirectory of the main


    "... are also supported." says to me that 'standard' ones are
    supported as well and they're *not*.

    > mailbox is considered a folder if '.' is the first character in its
    > name." It's not an explicit endorsement of Maildir++, but it touches
    > on what it considers a folder definition. I'm treading on hazy memory
    > here, but I believe Maildir++ is the definition provided by the
    > Courier folks.
    >

    So why isn't the class called mailbox.Maildir++ ? :)

    --
    Chris Green
     
    , Sep 26, 2009
    #5
  6. Jeff McNeil

    Guest

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

    Jeff McNeil <> wrote:
    > > > 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

    > >
    > > The doc says that "Folders of the style introduced by the Courier mail
    > > transfer agent are also supported. Any subdirectory of the main
    > > mailbox is considered a folder if '.' is the first character in its
    > > name."  It's not an explicit endorsement of Maildir++, but it touches
    > > on what it considers a folder definition. I'm treading on hazy memory
    > > here, but I believe Maildir++ is the definition provided by the
    > > Courier folks.
    > >
    > > --
    > > Thanks,
    > >
    > > Jeff
    > > mcjeff.blogspot.com

    >
    > http://wiki.mutt.org/?MuttFaq/Maildir
    >
    > That might help as well. You can have Mutt setup your folders using
    > that extended method.
    >

    Thanks, but no thanks. It creates 'folders' which aren't proper
    hierarchical directories at all and breaks all sorts of standard
    Unix/Linux ways of handling data. It's basically *horrible* and
    to be avoided at all costs if you actually want to have a local mail
    spool. It's OK if it's hidden behind an IMAP mail server or something
    but otherwise no.

    --
    Chris Green
     
    , Sep 26, 2009
    #6
  7. Jeff McNeil

    Guest

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

    Tim Roberts <> wrote:
    > wrote:
    > >
    > >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.

    >
    > The Maildir specification does not allow for subfolders. That was added in
    > Maildir++, and the subfolder names start with a dot. It's not a "wierd
    > extension thereof".


    No sub-folders within maildir folders but that's not what I was expecting.

    I was just expecting to be able to list my maildir mailboxes.

    --
    Chris Green
     
    , Sep 27, 2009
    #7
  8. Jeff McNeil

    Aahz Guest

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

    In article <h9o1bf$cmt$-september.org>,
    <> wrote:
    >Tim Roberts <> wrote:
    >> wrote:
    >>>
    >>>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.

    >>
    >> The Maildir specification does not allow for subfolders. That was added in
    >> Maildir++, and the subfolder names start with a dot. It's not a "wierd
    >> extension thereof".

    >
    >No sub-folders within maildir folders but that's not what I was expecting.
    >
    >I was just expecting to be able to list my maildir mailboxes.


    Now you know why *my* mutt uses mboxes. ;-)
    --
    Aahz () <*> http://www.pythoncraft.com/

    "....Normal is what cuts off your sixth finger and your tail..." --Siobhan
     
    Aahz, Oct 1, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matej Cepl

    mailbox.py examples (Maildir)

    Matej Cepl, Aug 6, 2003, in forum: Python
    Replies:
    1
    Views:
    477
    David M. Cooke
    Aug 6, 2003
  2. Replies:
    3
    Views:
    466
  3. Replies:
    0
    Views:
    355
  4. Replies:
    2
    Views:
    429
  5. Replies:
    0
    Views:
    405
Loading...

Share This Page