[augeas-devel] [Interfaces] Draft lense

Raphaël Pinson raphink at gmail.com
Wed Aug 20 14:41:47 UTC 2008


On Wed, Aug 20, 2008 at 4:35 PM, Free Ekanayaka <free at 64studio.com> wrote:

> Hi Raphaël,
>
> below you find another version of the lens, which implements many of
> the hints you gave me. I've removed the seq objects and now options of
> iface and mapping stanzas are properly parsed even when they are not
> prepended by spaces or tabs.



Great



> Pending issues now are:
>
> 1) The "auto" stanza does not support more than one interface, that
> means if the parser meets:
>
> auto lo eth0
>
> it will not generate the tree
>
> { "auto" = "lo" }
> { "auto" = "eth0" } }



I think my last email should fix this.



> 2) Comments inside a iface or mapping stanza break the parser. Ideally
> something like:
>
> # My outer comment
> iface eth0 inet static
>      address 192.168.1.1
> #    up flush-mail
>     netmask 255.255.255.0
>
> should generate:
>
> { "comment" = "My outer comment"}
> { "iface" = "eth0"
>    { "family" = "inet"}
>    { "method" = "static"}
>     { "address" = "192.168.1.1" }
>     { "comment" = "    up flush-mail" } }
>    { "netmask" = "255.255.255.0" }
>
> but I don't know how to tell the parser that the second comment
> belongs to the "iface" tree.
>


Same, my last email should answer this.
By the way, can we have trailing comments in interfaces, like

address 192.168.1.1  # what a cool IP

If this is the case, you'd have to support it also. I've settled down to map
this in entries as (comment|eol) instead of eol to end up an entry.



3) Lines splitted with the backslash character create problems, for
> example:
>
> iface lo inet \
>  loopback
>
> I've tried to replace:
>
> let spc          = Util.del_ws_spc
>
> with
>
> let spc = del /([ \t]+|[ \t]*\\\n[ \t]*)/ " "
>

You're missing some \. It should read

let spc = del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "


Yes, that's a lot of backslashes!


By the way, it is (imo) a good practice to make your test file as ugly as
possible (!). Ideally, you'd want your lens to support not only the nice
examples in the manpage, but virtually anything users could write that the
official parser could read, so I find that writing horrible (see
test_sudoers.aug) test files helps making sure that your lens will parse
them.


Ciao


Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080820/8b0571fa/attachment.htm>


More information about the augeas-devel mailing list