<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Jul 30, 2008 at 1:06 AM, David Lutterkort <span dir="ltr"><<a href="mailto:dlutter@redhat.com">dlutter@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, 2008-07-30 at 00:14 +0200, Raphaël Pinson wrote:<br>
><br>
><br>
> On Tue, Jul 29, 2008 at 9:02 PM, David Lutterkort <<a href="mailto:dlutter@redhat.com">dlutter@redhat.com</a>><br>
> wrote:<br>
<br>
</div><div class="Ih2E3d">>         New nodes are always added at the end (the same is true for<br>
>         'set')<br>
><br>
> That's useful indeed. I think it would be even more useful if<br>
> aug_insert returned the path of the newly inserted node. Let's say<br>
> there's already a .field before the one I'm inserting. Then this would<br>
> be useful:<br>
><br>
> $to_move = "/files/commenttest/field[1]";<br>
> $c_field = aug_ins(".field", "after", $to_move);<br>
> => $c_field = "/files/commenttest/.field[2]"<br>
> aug_mv($to_move, $c_field);<br>
<br>
</div>Yes, that would indeed be useful; unfortunately, that's not supported by<br>
the API right now, and would require adding a new call.<br>
<div class="Ih2E3d"><br>
> Is there a way to refer to the first child of a node in the public API<br>
> by the way? Or does it have to be done in the program using the API?<br>
><br>
> Say there is a parameter I need to put as the first child or a<br>
> 'record' node for it to work, how do I write the aug_insert command?<br>
<br>
</div>That can't be done right now, either; it would require more of XPath to<br>
be implemented by Augeas - it would be good if you could say<br>
'/files/etc/hosts/*[2]' to get the second child of '/files/etc/hosts'.<br>
<div class="Ih2E3d"><br>
>         Yeah, in its current form, Augeas only allows exactly one<br>
>         primitive that<br>
>         sets the label for a tree node (either key, label or seq)<br>
>         What's missing<br>
>         is forming tree labels from multiple such lenses so that you<br>
>         can say<br>
><br>
>                [ del /#[ \t]*/ "#" . label "." . key /[a-z]+/ . ... ]<br>
><br>
>         to prepend a '.' to the key parsed from the file. Initially, I<br>
>         marked<br>
>         that as an error, simply to be on the safe side. I now think<br>
>         it should<br>
>         be made possible, but it would require a fair amount of<br>
>         surgery in the<br>
>         internals (mostly lens.c, get.c, and put.c)<br>
><br>
><br>
> I guess it's not an easy change at all.<br>
<br>
</div>It's a little more involved than aug_mv ;)<br>
<font color="#888888"></font></blockquote><div><br><br>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.<br><br><br>Raphael<br>
</div></div></div>