[augeas-devel] Multiline values in INI Files (Was: Prefix for IniFile entries)

David Lutterkort lutter at redhat.com
Fri Aug 29 18:07:00 UTC 2008


On Fri, 2008-08-29 at 13:42 +0200, Raphaël Pinson wrote:


> Just saw another reason for not introducing indent in inifile.aug :
> some inifiles use indentation for multi-line values, like
> 
> 
> 
> key = this is a long
>    text that belongs 
>    to the same field

It's funny how many variations of this basic 'inifile' format there
really are; just indentation offers two different variants: samba-style
files where indentation is irrelevant and yum-style where indentation is
used for continuation.

> This kind of entries are very tricky to deal with (this is why I
> haven't put my hands on it yet) because ideally we would like to get

Have a look at yum.aug - Yum.kv_list parses an entry with continuation
lines into multiple tree nodes.

> { "key" = "this is a long\ntext that belongs\nto the same field" }
> 
> 
> but all I can think of getting is 
> 
> { "key" 
>    { "1" = "this is a long" }
>    { "2" = "text that belongs" }
>    { "3" = "to the same field" } }
> 
> or
> 
> { "key" = "this is a long\n   text taht belongs\n   to the same
> field" }

Heh .. so yum.aug is not what you are looking for. You are running into
a limitation of Augeas here: to do what you want, you'd need to write
something like

        [ key some_key . store value . ( del indentation . store
        value)* ]
        
i.e., make the value in a tree node the concatenation of several stores.
The Augeas implementation is just too simplistic in that area to allow
that - it would require some gyrations in the typechecker and the
parsers for get and put.

> which forces users to indent their value in a not very useful way.
> Furthermore, I believe adding a line to such a field should use the
> same indentation as the previous lines, which is currently not
> possible in augeas.

What's an example of where you'd want to do this kinda of mapping a
multiline entry into a single stripped entry rather than a list ? Some
sort of user-visible text ?

David





More information about the augeas-devel mailing list