[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Help with cobbler lens



On Fri, 2009-12-18 at 15:53 -0500, Bryan Kearney wrote:
> On 12/18/2009 02:24 PM, David Lutterkort wrote:
> > On Fri, 2009-12-18 at 08:45 -0500, Bryan Kearney wrote:
> >> On 12/17/2009 03:39 PM, David Lutterkort wrote:
> >>> On Thu, 2009-12-17 at 11:24 -0500, Bryan Kearney wrote:
> >>>> I took a first cut at a cobblersettings lens. You can see it at [1]. It
> >>>> is meant to parse cobbler settings files [2] which is a basic YAML 1.0
> >>>> syntax. It parses fine, but I am having issues saving a nested
> >>>> structure.
> >>>
> >>> When I run 'augparse cobblersettings.aug', I get a whole bunch of type
> >>> errors - do you get them, too ? Those need to be fixed first ...
> >>
> >>
> >> I see them. The error messages are a bit obscure and the lens seemed to
> >> be working. Is there a FAQ on reading the error messages?
> >
> > Now there is:
> > http://augeas.net/page/Ambiguities_or_what_do_those_error_messages_from_the_typechecker_mean
> 
> 
> This was helpful. It may be good to explain the syntax of the error 
> message is
> 
> line.column - line.column and the second line is omitted if it does not 
> change. I was too stupid to realize that.
> 
> I am not sitting on this version of th lens:
> 
> http://pastie.org/749121
> 
> and get this error when I try and parse:
> 
> Test run encountered exception:
> cobblersettings.aug:50.11-53.31:exception: overlapping lenses in tree 
> union.put
>      Example matched by both:  {  }
>      First lens: cobblersettings.aug:50.11-52.42
>      Second lens: cobblersettings.aug:48.29-.102

setting_list_suffix and indented_list_suffix both match the empty tree
{ } - I doubt that that is entirely intentional; for setting_list_suffix
you have:

        let setting_list_suffix = lbr . [value_list] . rbr . eol
        
value_list by itself creates a list of tree nodes. By encloding it in
another [] you are creating a node with no label, whose children will be
the list created by value_list.

It seems more logical to me to give that node a name, e.g. with [label
"list" . value_list], and do something similar for indented_list_suffix.
I am not sure if there is any semantic difference between the notation

  key: [value1, value2]

and

  key:
     - value1
     - value2

in YAML, but for purposes of the lens you need to distinguish the two
somehow in the tree. One way is to put the values for one form under a
"list" node, and the other under a "sequence" node or some such. It
should also be possible to put both under a "list" node, and put a
"sequence" node as the first child of the "list", and the entries as
further children of "list".

> 
> If I change line 49 slighlty (remove hte outer lens)
> 
> 
> http://pastie.org/749238
> 
> I get this:
> 
> cobblersettings.aug:50.11-53.31:exception: overlapping lenses in tree 
> union.put
>      Example matched by both:  { "value" = "''" }
>      First lens: cobblersettings.aug:50.11-52.42
>      Second lens: cobblersettings.aug:48.29-.100

The first match is from indendented_setting_list_suffix, the second from
indented_list_suffix. indented_setting_list_suffix matches { "value" =
"''" } because the regular expression kw matches it. You could fix this
by changing kw to '/[a-zA-Z0-9_]+/ - "value"', but that would assume
you'll never see a file that has a line 'value: something'. Other ways
to avoid that are (a) use something that's impossible to come from the
file for the labels of your lists, e.g. ".value" instead of "value", or
(b) store "mykey: myvalue" in a tree like 

        { "entry" = "mykey" { "value" = "myvalue" } }
        
David




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]