Re: :tree symbolic links, well

Bram Moolenaar <[email protected]> Tue, 28 Feb 2006 13:28:14 +0100
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Calmar wrote:

> I have a bunch of files and in the tree structure, there is also
> a sybolic link  pointing to another folder with files.
>=20
> I wanted to work on all those file, getting them with the :tree
> command. Since :tree does not follow symbolic links, I had to
> separately get the files in the symbolic link (pointing to a
> folder):
>=20
> (two times the use of :tree to get files in the symbolic link
> 'gal' (pointing to a directory) as well.
> ,----------------------------------------------------------------------=
-------
> | gall {virtual} :
> |     :tree gallery { skipdir =3D AAPDIR|zzz }
> |         :attr { publish =3D $(ftp_url)%file% } $name
> |         :publish $name
> |     :tree gallery/gal { skipdir =3D AAPDIR|zzz }
> |         :attr { publish =3D $(ftp_url)%file% } $name
> |         :publish $name
> `---
>=20
> So I'm just pointing out, a follow-symbolic-link flag for :tree
> might be a good idea maybe? (well, I solved it in my case with 2
> :tree statements, what is ok as well (as long there are not more
> symbolic links folders, I think))

Oh, that's not difficult.  I'll add the "follow" option.  Please try out
this patch:

Index: Commands.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/a-a-p/Exec/Commands.py,v
retrieving revision 1.132
diff -u -r1.132 Commands.py
--- Commands.py	9 Feb 2006 14:25:27 -0000	1.132
+++ Commands.py	28 Feb 2006 12:19:44 -0000
@@ -483,7 +485,7 @@
=20
     for k in dictlist[0].keys():
         if k not in [ "filename", "dirname", "reject", "skipdir",
-                                                          "contents", "n=
ame" ]:
+                                                "contents", "name", "fol=
low" ]:
             recipe_error(rpstack, _('Invalid attribute for :tree: %s') %=
 k)
=20
     dirpat =3D dictlist[0].get("dirname")
@@ -550,6 +552,9 @@
     else:
         options["contentsrex"] =3D None
=20
+    # Take over the "follow" option.
+    options["follow"] =3D dictlist[0].get("follow")
+
     aap_tree_recurse(rpstack, recdict, dictlist[0]["name"], options,
                                                          cmd_line_nr, co=
mmands)
=20
@@ -574,7 +579,7 @@
         # match the "skipdir" pattern.
         srex =3D options["skipdirrex"]
         if (os.path.isdir(f)
-                and not os.path.islink(f)
+                and (options["follow"] or not os.path.islink(f))
                 and (not srex or not srex.match(os.path.basename(f)))):
             aap_tree_recurse(rpstack, recdict, f, options,
                                                          cmd_line_nr, co=
mmands)

--=20
hundred-and-one symptoms of being an internet addict:
5. You find yourself brainstorming for new subjects to search.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \=
\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ =
\\\
\\\        download, build and distribute -- http://www.A-A-P.org        =
///
 \\\            help me help AIDS victims -- http://www.ICCF.nl         /=
//


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting langua=
ge
that extends applications into web and mobile media. Attend the live webc=
ast
and join the prime developer group breaking into this new coding territor=
y!
http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=3D=
121642