[augeas-devel] Hash-like entries across multiple lines
David Lutterkort
lutter at redhat.com
Mon Aug 25 21:46:23 UTC 2008
On Mon, 2008-08-25 at 10:22 +0200, Free Ekanayaka wrote:
> Hi,
>
> I am working on a lens to parse /etc/dhclient.conf (you find the
> current code below), and I would like to parse a sequence of
> statements like:
>
> send fqdn.fqdn \"grosse.fugue.com.\";
> send fqdn.encoded on;
>
> into a tree like:
>
> { "send"
> { "fqdn.fqdn" = "\"grosse.fugue.com.\"" }
> { "fqdn.encoded" = "on" } }
If the two send lines are consecutive, and you could generate that tree,
but it's not going to be pretty.
> Note that the two statements could also be in different positions in
> the file, not only one right after the other, for example:
>
> send fqdn.fqdn \"grosse.fugue.com.\";
> some statement;
> more statements at will;
> send fqdn.encoded on;
For this file, you'd have to create two separate send nodes -
intutively, the order of the tree nodes must be the same as the order of
the corresponding entries in the file.
> Currently I'm creating different tree nodes for the two statements (see
> test_dhclient.aug), like:
>
> { "send"
> { "fqdn.fqdn" = "\"grosse.fugue.com.\"" } }
> { "send"
> { "fqdn.encoded" = "on" } }
>
> However I'd like to be able to have a single /send node with all its
> hashed key/values pairs.
As Raphael said, it's not a big issue in practice, since you can refer
to the 'fqdn.encoded' value with '/send/fqdn.encoded' in both cases -
when you add new entries to the tree you have to know the exact
structure though.
David
More information about the augeas-devel
mailing list