|
From: Cameron S. <cam...@cs...> - 2009-07-17 00:47:32
|
I just found this very handy library, and I'm loving it. I'm using sections with options containing values that are comma-separated lists. These lists are meant to have 4 values, some of which can be empty. I have 2 questions: 1) I found the list_values parameter to turn off auto-conversion to list, because it was filtering out the empty entries (and returning lists with less than 4 entries). Is it possible to configure ConfigObj to leave the empty entries in the list? 2) If the list has an error I'd like to report the line number of the configuration file. Unfortunately this seems to be only available if ConfigObj has a parse error. Is there some way I can retrieve (or reconstruct) the line number corresponding to a key-value pair? Thanks, Cameron. |
|
From: Michael F. <fuz...@vo...> - 2009-07-17 09:52:48
|
Cameron Stone wrote: > I just found this very handy library, and I'm loving it. > > I'm using sections with options containing values that are > comma-separated lists. These lists are meant to have 4 values, some of > which can be empty. > > I have 2 questions: > > 1) I found the list_values parameter to turn off auto-conversion to > list, because it was filtering out the empty entries (and returning > lists with less than 4 entries). Is it possible to configure ConfigObj > to leave the empty entries in the list? > What do you mean by 'empty entries'? > 2) If the list has an error I'd like to report the line number of the > configuration file. Unfortunately this seems to be only available if > ConfigObj has a parse error. Is there some way I can retrieve (or > reconstruct) the line number corresponding to a key-value pair? > > There is no API for fetching line numbers of entries with ConfigObj I'm afraid. All the best, Michael Foord > Thanks, > Cameron. > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ |
|
From: Cameron S. <cam...@cs...> - 2009-07-17 11:22:22
|
Michael Foord wrote: > Cameron Stone wrote: >> I just found this very handy library, and I'm loving it. >> >> I'm using sections with options containing values that are >> comma-separated lists. These lists are meant to have 4 values, some of >> which can be empty. >> >> I have 2 questions: >> >> 1) I found the list_values parameter to turn off auto-conversion to >> list, because it was filtering out the empty entries (and returning >> lists with less than 4 entries). Is it possible to configure ConfigObj >> to leave the empty entries in the list? >> > > What do you mean by 'empty entries'? I mean the four entries look like: key_string = Value1,Value2, ,Value4 > There is no API for fetching line numbers of entries with ConfigObj I'm > afraid. No worries. I'm sure my users can figure it out. Thanks |
|
From: Michael F. <fuz...@vo...> - 2009-07-17 11:25:20
|
Cameron Stone wrote:
> Michael Foord wrote:
>
>> Cameron Stone wrote:
>>
>>> I just found this very handy library, and I'm loving it.
>>>
>>> I'm using sections with options containing values that are
>>> comma-separated lists. These lists are meant to have 4 values, some of
>>> which can be empty.
>>>
>>> I have 2 questions:
>>>
>>> 1) I found the list_values parameter to turn off auto-conversion to
>>> list, because it was filtering out the empty entries (and returning
>>> lists with less than 4 entries). Is it possible to configure ConfigObj
>>> to leave the empty entries in the list?
>>>
>>>
>> What do you mean by 'empty entries'?
>>
>
> I mean the four entries look like:
> key_string = Value1,Value2, ,Value4
>
And how should the missing entry look - it isn't an empty string (''),
it isn't None - it just isn't there. That should probably be a syntax error.
How about getting your users to put an empty string instead?
Michael
>
>> There is no API for fetching line numbers of entries with ConfigObj I'm
>> afraid.
>>
>
> No worries. I'm sure my users can figure it out.
>
> Thanks
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
|
|
From: Cameron S. <cam...@cs...> - 2009-07-17 12:19:35
|
Michael Foord wrote:
> Cameron Stone wrote:
>> Michael Foord wrote:
>>
>>> Cameron Stone wrote:
>>>
>>>> I just found this very handy library, and I'm loving it.
>>>>
>>>> I'm using sections with options containing values that are
>>>> comma-separated lists. These lists are meant to have 4 values, some of
>>>> which can be empty.
>>>>
>>>> I have 2 questions:
>>>>
>>>> 1) I found the list_values parameter to turn off auto-conversion to
>>>> list, because it was filtering out the empty entries (and returning
>>>> lists with less than 4 entries). Is it possible to configure ConfigObj
>>>> to leave the empty entries in the list?
>>>>
>>>>
>>> What do you mean by 'empty entries'?
>>>
>> I mean the four entries look like:
>> key_string = Value1,Value2, ,Value4
>>
>
> And how should the missing entry look - it isn't an empty string (''),
> it isn't None - it just isn't there. That should probably be a syntax error.
I was thinking it should imitate string.split:
>>> "Value1,Value2,,Value4".split(',')
['Value1', 'Value2', '', 'Value4']
I'm doing it that way manually at present, but I'm not sure what the
benefit of removing the missing entries is.
> How about getting your users to put an empty string instead?
|
|
From: David H. <neg...@gm...> - 2009-07-17 14:15:21
|
How would validation work for non-string list specifications? I.e. -- what value should an empty entry be for an int_list? Ditto for the other types (float, bool, etc..). I suppose an argument can be made to use None under these circumstances. But then is it more or less intuitive for string lists to use '' instead of None? On Fri, Jul 17, 2009 at 08:31, Michael Foord <fuz...@vo...>wrote: > > Hmm... well on reflection it ought to either be a syntax error or come > in as empty string. I guess empty string makes most sense. I'm doing an > update to ConfigObj soon to address a couple of issues and see if I can > include this. > > Thanks > > Michael > > |
|
From: Michael F. <fuz...@vo...> - 2009-07-17 14:23:32
|
David Hostetler wrote: > > How would validation work for non-string list specifications? > > I.e. -- what value should an empty entry be for an int_list? Ditto > for the other types (float, bool, etc..). > > I suppose an argument can be made to use None under these > circumstances. But then is it more or less intuitive for string lists > to use '' instead of None? > > Hmm... unfortunately that's a very good point. Perhaps an alternative set of validation functions that allow empty values and replace them with None. From a validation point of view either an empty entry is either acceptable or not depending on the use case. Michael > On Fri, Jul 17, 2009 at 08:31, Michael Foord > <fuz...@vo... <mailto:fuz...@vo...>> wrote: > > > Hmm... well on reflection it ought to either be a syntax error or come > in as empty string. I guess empty string makes most sense. I'm > doing an > update to ConfigObj soon to address a couple of issues and see if > I can > include this. > > Thanks > > Michael > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > ------------------------------------------------------------------------ > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |
|
From: Michael F. <fuz...@vo...> - 2009-07-17 12:31:32
|
Cameron Stone wrote:
> Michael Foord wrote:
>
>> Cameron Stone wrote:
>>
>>> Michael Foord wrote:
>>>
>>>
>>>> Cameron Stone wrote:
>>>>
>>>>
>>>>> I just found this very handy library, and I'm loving it.
>>>>>
>>>>> I'm using sections with options containing values that are
>>>>> comma-separated lists. These lists are meant to have 4 values, some of
>>>>> which can be empty.
>>>>>
>>>>> I have 2 questions:
>>>>>
>>>>> 1) I found the list_values parameter to turn off auto-conversion to
>>>>> list, because it was filtering out the empty entries (and returning
>>>>> lists with less than 4 entries). Is it possible to configure ConfigObj
>>>>> to leave the empty entries in the list?
>>>>>
>>>>>
>>>>>
>>>> What do you mean by 'empty entries'?
>>>>
>>>>
>>> I mean the four entries look like:
>>> key_string = Value1,Value2, ,Value4
>>>
>>>
>> And how should the missing entry look - it isn't an empty string (''),
>> it isn't None - it just isn't there. That should probably be a syntax error.
>>
>
> I was thinking it should imitate string.split:
>
>
>>>> "Value1,Value2,,Value4".split(',')
>>>>
> ['Value1', 'Value2', '', 'Value4']
>
> I'm doing it that way manually at present, but I'm not sure what the
> benefit of removing the missing entries is.
>
>
Hmm... well on reflection it ought to either be a syntax error or come
in as empty string. I guess empty string makes most sense. I'm doing an
update to ConfigObj soon to address a couple of issues and see if I can
include this.
Thanks
Michael
>> How about getting your users to put an empty string instead?
>>
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
|
|
From: Cameron S. <cam...@cs...> - 2009-07-17 13:40:01
|
Michael Foord wrote: > Hmm... well on reflection it ought to either be a syntax error or come > in as empty string. I guess empty string makes most sense. I'm doing an > update to ConfigObj soon to address a couple of issues and see if I can > include this. That's great. Thanks, again. Cameron. |