[augeas-devel] How can I reverse the order of the parsed keys?
Francis Giraldeau
francis.giraldeau at usherbrooke.ca
Fri Feb 4 05:17:34 UTC 2011
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
More information about the augeas-devel
mailing list