Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: What does the list_folders() method of mailbox.Maildir actuallydo (if anything)?

Reply
Thread Tools

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

 
 
Jeff McNeil
Guest
Posts: n/a
 
      09-25-2009
On Sep 25, 3:22*pm, tinn...@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.

--
Thanks,

Jeff
mcjeff.blospot.com
 
Reply With Quote
 
 
 
 
tinnews@isbd.co.uk
Guest
Posts: n/a
 
      09-25-2009
Jeff McNeil <> wrote:
> On Sep 25, 3:22Â*pm, tinn...@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

 
Reply With Quote
 
 
 
 
Jeff McNeil
Guest
Posts: n/a
 
      09-25-2009
On Sep 25, 4:13*pm, tinn...@isbd.co.uk wrote:
> Jeff McNeil <j...@jmcneil.net> wrote:
> > On Sep 25, 3:22*pm, tinn...@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



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
 
Reply With Quote
 
Jeff McNeil
Guest
Posts: n/a
 
      09-25-2009
On Sep 25, 4:28*pm, Jeff McNeil <j...@jmcneil.net> wrote:
> On Sep 25, 4:13*pm, tinn...@isbd.co.uk wrote:
>
>
>
>
>
> > Jeff McNeil <j...@jmcneil.net> wrote:
> > > On Sep 25, 3:22*pm, tinn...@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

>
> 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
 
Reply With Quote
 
tinnews@isbd.co.uk
Guest
Posts: n/a
 
      09-26-2009
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

 
Reply With Quote
 
tinnews@isbd.co.uk
Guest
Posts: n/a
 
      09-26-2009
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

 
Reply With Quote
 
tinnews@isbd.co.uk
Guest
Posts: n/a
 
      09-27-2009
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

 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      10-01-2009
In article <h9o1bf$cmt$>,
<> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
invoke a method by reflection£¬the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
BC30289: Statement cannot appear within a method body. End of method assumed. Carlos Oliveira ASP .Net 0 08-19-2004 07:51 PM
Difference between Delete method and RemoveRow method CW ASP .Net 0 04-01-2004 01:07 AM
ASP.NET: BC30289: Statement cannot appear within a method body. End of method assumed. Mike Wilmot ASP .Net 0 12-15-2003 07:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57