[Cook] Enumerating leaf directories

Pendergraft, Jerry JPendergraft at sjm.com
Sat Mar 3 14:22:35 EST 2007


Normally within a cook file you have some kind of list of "project" files - a manifest as it were.
There are a number of ways to get that, using find, glob, in a file list. etc
> 1. I don't think find can do it unaided.
Assuming your files are .html then
 project_files = [collect find . -type f -name [quote '*.html'] -print | sed -e [quote 's:^\./'::']];

If your project is controlled using aegis then it is 
 project_files = [collect aelpf];

But whatever lets just say you have it loaded somehow in a cook list -- project_files.

So now the leaf directories you seek are given by:
 leaf_directories = [stringset [dirname [project_files]]];

But if you are wanting the leaf directories in order to find the project files .....  Normally you want to start with the list of files. 


Jerry Pendergraft                              voice:651-523-6935
St.Jude Medical                                mobil:651-491-0163
Atrial Fibrillation Division                email:jpendergraft at sjm.com
1350 Energy Lane
St.Paul, MN  55108

-----Original Message-----
From: cook-users-bounces+jpendergraft=sjm.com at auug.org.au on behalf of Reuben Thomas
Sent: Fri 02-Mar-07 17:17
To: Cook users list
Subject: [Cook] Enumerating leaf directories
 
Here I am, attacking my problem step by step!

Step 1: I need to find my sources. They are, effectively, the leaf 
directories of the tree. How best to enumerate them? Two hints:

1. I don't think find can do it unaided.

2. If you get a complete list of directories, and sort it, you can then use 
the trick that a directory is a leaf if it is either the last in the list, 
or is not a prefix of the following directory.

In case it's not obvious: I know how to solve this problem (the above *is* a 
solution), but I'm clueless how best to express it in Cook. In the worst 
case, I can just write an external script to make the list, but I imagine 
there's a better way to do it in Cook.

-- 
http://rrt.sc3d.org/ | free, a.  already paid for (Peyton Jones)
_______________________________________________
Cook-users mailing list
Cook-users at auug.org.au
http://www.auug.org.au/mailman/listinfo/cook-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20070302/91340cd4/attachment.htm>


More information about the Cook-users mailing list