[augeas-devel] Help splitting a key on a slash character
David Lutterkort
lutter at redhat.com
Tue May 11 17:08:24 UTC 2010
On Tue, 2010-05-11 at 09:57 -0700, Marc Riddle wrote:
>
> I was hoping someone could help me out with a new lens I'm working on
> (for sssd.conf in rhel6/recent fedoras). It's pretty much a straight
> ini file, with one problem. There are 'domain' sections whose headers
> look like '[domain/LOCAL]', '[domain/LDAP]', which I'm figuring I'll
> split up inside of a 'domain' label, with a tree that ends up
> something like:
>
> { "domain"
> { "LOCAL"
> { "foo" = "bar" } }
> { "LDAP"
> { "foo" = "bar" } } }
>
> but I'm having a hell of a time splitting on the '/'. I was wondering
> if anyone could point me to an existing lens that does something
> similar, or just give me some advice on the best way to proceed with
> this...
To repeat what I said on IRC: given your input, you can't produce the
above tree; what you can produce is
{ "domain"
{ "LOCAL"
{ "foo" = "bar" } } }
{ "domain"
{ "LDAP"
{ "foo" = "bar" } } }
The difference won't matter much to users of the tree - they can still
talk about '/domain/LDAP/foo'.
To do the actual splitting, save the attached file 'split_test.aug' and
run it through augparse.
David
-------------- next part --------------
module Split_Test =
let dels (s:string) = del s s
let word = /[A-Za-z]+/
let l = [ dels "[" . key word . dels "/" .
[ key word ] . dels "]" ]
test l get "[domain/LDAP]" = ?
More information about the augeas-devel
mailing list