[augeas-devel] Review of dhcpd lens

David Lutterkort lutter at redhat.com
Sat Jul 24 00:54:31 UTC 2010


On Tue, 2010-07-13 at 11:31 -0400, Francis Giraldeau wrote:
> I send dhcpd.conf lens for review, since it's an early version. Feel
> free to provide comments on it. 

Looks pretty good to me. I am far from an expert on dhcpd.conf, but your
tests pass and seem to produce sensible results.

The only thing is that the one of the tests still has a '= ?', and
there's a few debug prints left in it.

As for the FIXME comment about stripping quotes, I see a few options:
     1. Do the somewhat crazy legwork that I did for the Sysconfig lens
        to handle quoted and unquoted strings and strip them of their
        quotes - very unpleasant
     2. Expand 'struct regexp' so that it can act as a filter for quoted
        strings; to construct such a regexp from the language, we'd need
        a helper function like 'quoted_string RE QUOTES DEFQUOTE WS'
        where RE is the regular expression matching bare words, QUOTES
        is a string listing the quote characters, DEFQUOTE the default
        quote character, and WS a regexp matching whitespace characters;
        i.e. 'quoted_string /[a-z]+/ "'\"" "\"" /[ \t]*/' would match
        bare words /[a-z]+/ or strings enclosed in single or double
        quotes matching /([a-z]+|[ \t]*)*/. Upon get, we strip quote
        characters if they are present, and restore them upon put.
     3. Implement canonizers from Nate Foster's paper fully; we'd need a
        bit of a wrinkle on them, since we need to pick different
        representatives depending on whether the string needs quotes or
        not. This is definitely the hardest one to implement, but would
        also have the side-benefit of making it possible to handle
        unimportant things like whitespace in XML more flexibly

> I tried to follow most of dhclient lens tree structure, both are almost
> identical. There is a difference in handling new lines, because I wanted
> to allow many statements ont the same line. 
> 
> BTW, Util.empty creates an empty tree "{ }". We can't select it in the
> XPath interface, and don't even know if we can create such node. In this
> case, what is the real purpose of it? 

It serves as a placeholder so that comments etc. get restored in the
'right' place. It allows the put part to distinguish whether a line was
deleted before or after an empty line. They can not be manipulated
through the API on purpose.

David





More information about the augeas-devel mailing list