[augeas-devel] Is there way to get path of inserted label?

Josef Reidinger jreidinger at suse.com
Tue Mar 14 10:12:45 UTC 2017


Good morning to list,
Let me at first get context. I am using augeas ruby bindings to do some
automatic changes in configuration files. I build some tools around
allowing easier access to augeas, but I have now one challenge.

In general I have set of modifications, additional entries and removed
entries. My challenge is that path is not stable, so when new entry is
added or removed from array like #comment, then it changes path of
other items in array.

So consider this scenario. I need to modify two comments, remove two
comments and add comment before another comment. The first part is
easy and I use set. The second part I already solved as I know original
path and do it in reverse order so e.g. remove #comment[50] and
#comment[36]. Then I want to add new #comment before original
#comment[10] but it is no longer #comment[10] and I also do not know
what will be number of new comment ( ok, in this case I know it is path
of comment I inserted before, but sometimes I need to add it before
another key like "inst #comment before $prefix/alias[5]" then is there
easy way how to get path of newly inserted label? like
$prefix/#comment[16] ?

Also is there way how to get what is old path? Value is not unique,
especially in comments and I find manually counting and changing all
indexes quite complex.

Thanks for help and tips.

Josef




More information about the augeas-devel mailing list