[augeas-devel] First tests with aug mv
Raphaël Pinson
raphink at gmail.com
Wed Jul 30 05:44:15 UTC 2008
On Wed, Jul 30, 2008 at 1:06 AM, David Lutterkort <dlutter at redhat.com>wrote:
> On Wed, 2008-07-30 at 00:14 +0200, Raphaël Pinson wrote:
> >
> >
> > On Tue, Jul 29, 2008 at 9:02 PM, David Lutterkort <dlutter at redhat.com>
> > wrote:
>
> > New nodes are always added at the end (the same is true for
> > 'set')
> >
> > That's useful indeed. I think it would be even more useful if
> > aug_insert returned the path of the newly inserted node. Let's say
> > there's already a .field before the one I'm inserting. Then this would
> > be useful:
> >
> > $to_move = "/files/commenttest/field[1]";
> > $c_field = aug_ins(".field", "after", $to_move);
> > => $c_field = "/files/commenttest/.field[2]"
> > aug_mv($to_move, $c_field);
>
> Yes, that would indeed be useful; unfortunately, that's not supported by
> the API right now, and would require adding a new call.
>
> > Is there a way to refer to the first child of a node in the public API
> > by the way? Or does it have to be done in the program using the API?
> >
> > Say there is a parameter I need to put as the first child or a
> > 'record' node for it to work, how do I write the aug_insert command?
>
> That can't be done right now, either; it would require more of XPath to
> be implemented by Augeas - it would be good if you could say
> '/files/etc/hosts/*[2]' to get the second child of '/files/etc/hosts'.
>
> > Yeah, in its current form, Augeas only allows exactly one
> > primitive that
> > sets the label for a tree node (either key, label or seq)
> > What's missing
> > is forming tree labels from multiple such lenses so that you
> > can say
> >
> > [ del /#[ \t]*/ "#" . label "." . key /[a-z]+/ . ... ]
> >
> > to prepend a '.' to the key parsed from the file. Initially, I
> > marked
> > that as an error, simply to be on the safe side. I now think
> > it should
> > be made possible, but it would require a fair amount of
> > surgery in the
> > internals (mostly lens.c, get.c, and put.c)
> >
> >
> > I guess it's not an easy change at all.
>
> It's a little more involved than aug_mv ;)
>
All good things in good time :) Augeas is already very useful, and is only
going to get better. I'll be happy to help where my skills can be useful.
Raphael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080730/b3b49621/attachment.htm>
More information about the augeas-devel
mailing list