[augeas-devel] Improving the properties lens, issues with empty values
Carlos Sanchez
carlos at apache.org
Mon Apr 9 17:36:28 UTC 2012
Thanks Dominic that works!
I'm going to start switching our properties files manipulation in
puppet to use augeas and if it's all good I'll create a pull request.
On Sun, Apr 8, 2012 at 12:46 PM, Dominic Cleal <dcleal at redhat.com> wrote:
> Hi Carlos,
>
> On 07/04/12 10:09, Carlos Sanchez wrote:
>> I'm making a couple changes to the properties lens, but I'm struggling
>> to get empty values working
>>
>> I've made a fork on github [1] with the tests [2] that currently fail
>> with something like
>>
>> mykey=
>>
>> A snippet of the lens:
>>
>> let sepch = del /[ \t]*=[ \t]*/ "="
>> let value_to_eol = /[^ \t\n](.*[^ \t\n])?/
>> let entry = /[A-Za-z][A-Za-z0-9._]+/
>> let property = [ indent . key entry . sepch . store value_to_eol . eol ]
>>
>> Any suggestions?
>> may need to reorganize it and change more than just value_to_eol?
>
> The first change I'd try would be to make the store value_to_eol
> optional, giving you an entry without any value:
>
> let property = [ indent . key entry . sepch . (store value_to_eol)? . eol ]
>
> You'll find when you run augparse against the test that it'll fail
> due to an ambiguity when there's no value_to_eol:
>
> 'AA= \n' can be split into
> 'AA=|=| \n'
>
> and
> 'AA= |=|\n'
>
> The single space can be consumed by either the sepch lens or the
> eol. To fix this, you can move the trailing space consumption
> out of sepch and into the optional brackets created above:
>
> let sepch = del /[ \t]*=/ "="
> let property = [ indent . key entry . sepch . (indent . store value_to_eol)? . eol ]
>
> This appears to work. The unit test needs a small change for the
> empty.property line. An empty node would be stored with no value
> rather than an empty string:
>
> { "empty.property" }
>
> Let us know once you're happy with the changes and we'll merge
> them.
>
> Thanks,
>
> --
> Dominic Cleal
> Red Hat Consulting
> m: +44 (0)7817 878113
More information about the augeas-devel
mailing list