[augeas-devel] First tests with aug mv

Raphaël Pinson raphink at gmail.com
Tue Jul 29 22:14:02 UTC 2008


On Tue, Jul 29, 2008 at 9:02 PM, David Lutterkort <dlutter at redhat.com>wrote:

> On Tue, 2008-07-29 at 13:04 +0200, Raphaël Pinson wrote:
> > There's a few things to note here:
> > * mv works ! Thank you David :)
>
> Cool .. then I'll commit it upstream.
>
> > * save works but is not happy :(
>
> That seems to be related to something else .. I could not reproduce the
> problem you were having. Do you have any other lenses in the directory
> where CommentTest lives ?


Yes, there are. I'll try to put CommentTest in a separate dir and test
again. I'll let you know how it goes.


> * "field=toto" got moved from 1st place to 2nd placed when it got
> > commented. This is a side effect to this (un)commenting method I
> > hadn't considered.
>
> Yeah, if you want to avoid that, you have to insert the new node
> beforehand, e.g.
>
>  ins .field after /files/commenttest/field[1]
>   mv /files/commenttest/field[1] /files/commenttest/.field
>
> 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);


This way I would be sure to not make a mistake :)


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?



> * dealing with key in the lens is quite tricky. While it's possible to
> declare a c_key function, it will only take a string, since the
> contents of Util.del_str kw cannot be assigned to label currently.

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.


Raphael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080730/660479db/attachment.htm>


More information about the augeas-devel mailing list