[augeas-devel] Help splitting a key on a slash character

Marc Riddle mriddle at valueclick.com
Tue May 11 17:47:04 UTC 2010


That was a huge help, I'm very close now, but can't quite seem to get it
right. Here's what I have right now:

--- snip ---
module Sssd =
  autoload xfm

  let eol = Util.del_str "\n"

  let key_re = /[^#;:= \t\n[\/]+/

  let dels (s:string) = del s s

  let eq = del /[ \t]*=[ \t]*/ "="

  let secname = /[^]\/]+/

  let value = /[^ \t\n][^\n]*/

  let comment = [ del /([;#].*)?[ \t]*\n/ "\n" ]

  let kv = [ key key_re . eq . store value . eol ]

  let domainsechead = dels "[" .key secname . dels "/" . [key secname] .
dels "]" . del /[ \t]*[;#]?.*/ "" . eol

  let nodomainsechead = dels "[" . key secname . dels "]" . del /[
\t]*[;#]?.*/ "" . eol

  let sechead = domainsechead | nodomainsechead

  let entry = comment | kv

  let section = [ sechead . entry* ]

  let lns = (comment) * . (section) *

  let filter = (incl "/etc/sssd/sssd.conf")
      . Util.stdexcl

  let xfm = transform lns filter

   let conf = "
[main]
foo = foobar
[domain/LDAP]
bar = barfoo
"

   test Sssd.lns get conf =
      {}
      { "main"
        { "foo" = "foobar" } }
      { "domain"
        { "LDAP"
         { "bar" = "barfoo" } } }
        { "LDAP"
         { "bar" = "barfoo" } } }


--- snip ---

Which results in the following tree:

{ 
  {  }
  { "main"
    { "foo" = "foobar" }
  }
  { "domain"
    { "LDAP" }
    { "bar" = "barfoo" }
  }
}

How do I get 'bar' to be inside of 'LDAP'? Sorry if these are basic
questions, I'm just getting up to speed with augeas, but am hoping to get
several more lenses written as I get more comfortable here...


Thanks,

Marc


On 5/11/10 10:08 AM, "David Lutterkort" <lutter at redhat.com> wrote:

> 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
> 
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel





This email and any files included with it may contain privileged,
proprietary and/or confidential information that is for the sole use
of the intended recipient(s).  Any disclosure, copying, distribution,
posting, or use of the information contained in or attached to this
email is prohibited unless permitted by the sender.  If you have
received this email in error, please immediately notify the sender
via return email, telephone, or fax and destroy this original transmission
and its included files without reading or saving it in any manner.
Thank you.




More information about the augeas-devel mailing list