[augeas-devel] How can I reverse the order of the parsed keys?

Raphaël Pinson raphink at gmail.com
Fri Feb 4 08:49:06 UTC 2011


Hello,


While Francis' method works, I think generally it is better for the
users to stick to the order in the conffiles, it will be less
confusing when they try to figure out how the lens works. The Xpath
syntax will then allow to filter on attributes rather than nodes if
necessary.


Raphaël




On Fri, Feb 4, 2011 at 6:17 AM, Francis Giraldeau
<francis.giraldeau at usherbrooke.ca> wrote:
> On Fri, 2011-02-04 at 16:39 +1300, Steve Shipway wrote:
>> What I’m trying to do is to parse an MRTG config file, which has lines
>> in this format:
>>
>>
>>
>> Directive[targetname]: value
>>
>>
>>
>> for some Directive, targetname and value.  This would be relatively
>> easy to parse into a format of …/Directive/targetname=value
>>
>>
>>
>> However, due to the nature of the configuration file, I’d like it to
>> appear in the /files tree in the format
>>
>>
>>
>> …/targetname/Directive = value
>>
>>
>>
>> I can’t see a way to do this, since Augeas appears to process the file
>> strictly in one direction only.
>
> Yeah, but there is a twist if you list targetnames. But that depends on
> the situation.
>
> module Mrtg =
>
> (* d[t] :v *)
>
> let dels (s:string) = del s s
>
> let record (targetname:string) = [ label targetname . [ key /[a-z]+/ .
> dels "[" . dels targetname . dels "]:" . store /[a-z]+/ ] ]
>
> let cfg = record "foo" | record "bar"
>
> test cfg get "somedirective[foo]:somevalue" = { "foo" { "somedirective"
> = "somevalue" }}
>
> Francis
>
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel




More information about the augeas-devel mailing list