Re: exclusion in file patterns
Bram Moolenaar <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
Tim Hemel wrote:
> On Thu, Sep 11, 2003 at 05:51:40PM +0200, Bram Moolenaar wrote:
> >
> > Tim Hemel wrote:
> >
> > I think the :tree command comes closest:
> >
> > http://www.a-a-p.org/exec/ref-commands.html#cmd-tree
> >
> > It's strange that there is no Python function for this.
> >
> > I was thinking of improving the :tree command yesterday. If you run
> > into something you can't do what you want, make suggestions.
>
> The problem with the tree command is that when I use my filespec as an
> argument to certain actions, I have to use a separate :tree command.
> That forces me to express myself in terms of commands, instead of
> thinking in terms of filespecs.
True, this requires a separate block of commands. The idea is that the
same :tree command can also be used to execute commands, such as
changing the protection bits after copying a file.
> If I could make a filespec that gets all files in a directory
> recursively, and where I can exclude certain files, that would be a
> lot nicer. It's not hard to write the Python code to get these files,
> but how would one express it in aap syntax?
>
> FILES = tree("www/*",exclude="CVS,AAPDIR,*.bak")
I try to avoid inventing things like this. It quickly turns into
something complicated. If you look at Ant they have something that
selects files on various properties, such as owner, protection, etc.
Unfortunately, I don't know of a standard Python function that can be
used for this. An advanced version of glob() that recurses into
directories would at least be very welcome.
I have to admit that the current solution with ":tree" is a bit longer:
FILES =
:tree www {reject = *.bak} {skipdir = CVS|AAPDIR}
_caller.FILES += $name
Note that "skipdir" was added recently, it won't work in older Aap
versions.
I recently suggested that "_caller" can be omitted, but I haven't
received feedback on the idea.
It would be possible to abandon the use of ":tree" and add a tree()
function instead. For executing commands on a selection of files you
would then do:
@for name in tree(...):
:do your thing
Hmm, that's actually quite nice. Would it be worth inventing a tree()
function for this reason?
--
"Software is like sex... it's better when it's free."
-- Linus Torvalds, initiator of the free Linux OS
Makes me wonder what FSF stands for...?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
\\\ Project leader for A-A-P -- http://www.A-A-P.org ///
\\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf