[Tutor] Directory Structure

Alan Gauld alan.gauld at yahoo.co.uk
Fri Sep 29 19:23:45 EDT 2017


On 29/09/17 20:34, Chris wrote:

> I want to store some kind of representation of the tree in memory when
> the code runs. Then I could not only move the mails but also create
> lists, e.g. a table with mail headers.

Thanks for the extra detail but...

Probably the reason you can't find any modules out there is this
is not something anyone would normally want to do. It would
consume quite a lot of memory and provide little advantage
(a little bit of speed) compared to building the lists (or
copying the files) dynamically as you traverse the real
directories.

> Directory tree, it's called Maildir. Server is dovecot.
> 
> Create an archive elsewhere. Copything the mails isn't the problem.
> Finding them is easy. I just don't know howto represent the tree in the
> script.

Are you sure you really need to?
The oly reason I can see for trying to do that would
be if you were trying to build some kind of dynamic query
engine that processed a lot of different queries in a single
session.

If you know before you run the code what you need to extract
you are usually better just scanning the folders and processing
the data as you find it. That way you only traverse the tree
once rather than once to build the tree then search the tree
(in memory) and go back again to process the files.

If you really need it in memory there are some generic modules
for building tree structures in memory - you will need to
define the mail objects of course the modules are data neutral,
they just allow you to create and navigate the tree, populating
it with whatever objects you want.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list