[augeas-devel] Re: Multiline values in INI Files

Raphaël Pinson raphink at gmail.com
Fri Aug 29 14:56:02 UTC 2008


On Fri, Aug 29, 2008 at 3:30 PM, Benjamin Pierce <bcpierce at cis.upenn.edu>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
>>
>> 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
>>
>> { "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" }
>>
>
>
> In developing Boomerang, we've found that you really need to extend the
> foundations of the language to deal with such examples effectively -- in
> principle, they can be handled using just plain lenses, but in practice the
> details become too horrible.  Our paper on Quotient Lenses to be presented
> at the International Conference on Functional Programming in a few weeks,
> and available off the Boomerang home page
>
>    http://www.seas.upenn.edu/~harmony/<http://www.seas.upenn.edu/%7Eharmony/>
>
> gives details of our design.  I suspect that it could be adapted to Augeas
> pretty easily.
>



I tried to read the paper. It's very interesting.

Let me see if I understand how q-lenses would apply to this particular
problem in Augeas.

I would write a lens that would actually keep the indentation, in this
fashion:

{ "key" = "this is a long\n   text that belongs\n   to the same field" }


but then I would add a q-lens to the front of it, which would take the
abstract part of this lens (which contains the ugly indentation) and parse
it in a reversible way, changing all /\n[ \t]+/ into "\n" to make it look
nice. The default value for the indentation would then be "\n " so that the
abstract line "this is a long\ntext that belongs\nto the same field" would
get computed through the q-lens (in the case of a create, not of a put) into
"this is a long\n text that belongs\n to the same field".


Not sure I got it right... and I'm not sure either that it solves the issue
of having the same indentation level throughout the string... or did I miss
something?


Raphaël




> On Aug 29, 2008, at 7:50 AM, augeas-devel-request at redhat.com wrote:
>
>  Date: Fri, 29 Aug 2008 13:42:05 +0200
>> From: " Rapha?l Pinson " <raphink at gmail.com>
>> Subject: [augeas-devel] Multiline values in INI Files (Was: Prefix for
>>        IniFile entries)
>> To: "Free Ekanayaka" <free at 64studio.com>
>> Cc: augeas-devel at redhat.com
>> Message-ID:
>>        <8ce271500808290442g11b3e188u68306539e4f4bdeb at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> On Wed, Aug 27, 2008 at 5:59 PM, Free Ekanayaka <free at 64studio.com>
>> wrote:
>>
>>  Hi Raphaël,
>>>
>>> |--==> On Wed, 27 Aug 2008 12:41:38 +0200, "Raphaël Pinson" <
>>> raphink at gmail.com> said:
>>>
>>>  RP> I think we could add it to inifile.aug. Making it optional is
>>> another
>>> story.
>>>  RP> Options in augeas lenses are not easy to deal with since you cannot
>>> have
>>>  RP> optional arguments to functions nor default values for parameters in
>>>  RP> functions. That's why inifile.aug ended up with pretty big calls for
>>> entry,
>>>  RP> record and lns, and additionnal record_noempty and lns_noempty to
>>> deal
>>> with
>>>  RP> files that don't accept empty lines. All the same, there would be a
>>> need for
>>>  RP> entry_noindent, record_noindent and record_noempty_noindent calls,
>>> which
>>>  RP> makes it a bit ugly to my taste. Ideas on this are welcome.
>>>
>>> If introducing ugly _noindent declarations is the only viable way at
>>> the moment, but it makes inifile.aug enough flexible to deal with all
>>> kind of INI files, then I would go for it. Of course Better
>>> alternatives are welcome.
>>>
>>>
>>
>> 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
>>
>>
>> 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
>>
>> { "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" }
>>
>>
>> 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.
>>
>>
>>
>>
>> Raphaël
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080829/6c957789/attachment.htm>


More information about the augeas-devel mailing list