|
From: David H. <neg...@gm...> - 2008-11-18 22:23:25
|
I'm finally getting around to taking advantage of Validator (have been
using configobj for awhile), and unfortunately I'm finding that it
currently lacks a capability that is (for my purposes) a necessity.
Basically, I need a repetition mechanisms that works for keyword=value
pairs. The '__many__' feature works for repeated subsections within a
given section, but I need something that lets me validate repeated
keywords within a given section.
I.e., for a config like:
[somesection]
foo = 1
bar = 2
I could define a configspec like so:
[somesection]
__many__ = integer(default=0)
That would allow a config file to include an arbitrary number of
keyword=value pairs in the 'somesection' section, and I don't need a
priori knowledge of the full set (the very same logical justification
for the existing __many__ subsection feature).
Without this capability, I'm compelled to restructure to something like this:
[somesection]
[[foo]]
value = 1
[[bar]]
value = 2
with a configspec like:
[somesection]
[[__many__]]
value = integer(default=0)
Which in my opinion is less syntactically efficient for the nature of
the data I need to support. That is - it forces another layer of
config sectional hierarchy where it isn't needed and it muddies the
namespace unnecessarily.
Is there a way to do this in the current implementation that I haven't
discovered, and if not - could this possibly be added as a new
capability?
regards,
-David
|
|
From: Michael F. <fuz...@vo...> - 2008-11-18 22:31:22
|
David Hostetler wrote: > I'm finally getting around to taking advantage of Validator (have been > using configobj for awhile), and unfortunately I'm finding that it > currently lacks a capability that is (for my purposes) a necessity. > > Basically, I need a repetition mechanisms that works for keyword=value > pairs. The '__many__' feature works for repeated subsections within a > given section, but I need something that lets me validate repeated > keywords within a given section. > > I.e., for a config like: > > [somesection] > foo = 1 > bar = 2 > > > I could define a configspec like so: > > [somesection] > __many__ = integer(default=0) > > That's a good idea. Let me check my time machine: http://www.voidspace.org.uk/python/weblog/arch_d7_2008_10_25.shtml#e1020 Yup, in Subversion and due for release soon. In the meantime you can try out the version in Subversion. https://svn.pythonutils.python-hosting.com/trunk/pythonutils/configobj.py Michael Foord > That would allow a config file to include an arbitrary number of > keyword=value pairs in the 'somesection' section, and I don't need a > priori knowledge of the full set (the very same logical justification > for the existing __many__ subsection feature). > > Without this capability, I'm compelled to restructure to something like this: > > [somesection] > [[foo]] > value = 1 > [[bar]] > value = 2 > > > with a configspec like: > > [somesection] > [[__many__]] > value = integer(default=0) > > > Which in my opinion is less syntactically efficient for the nature of > the data I need to support. That is - it forces another layer of > config sectional hierarchy where it isn't needed and it muddies the > namespace unnecessarily. > > > Is there a way to do this in the current implementation that I haven't > discovered, and if not - could this possibly be added as a new > capability? > > regards, > > -David > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > 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: David H. <neg...@gm...> - 2008-11-18 22:57:11
|
On Tue, Nov 18, 2008 at 5:31 PM, Michael Foord <fuz...@vo...> wrote: > > That's a good idea. Let me check my time machine: > > http://www.voidspace.org.uk/python/weblog/arch_d7_2008_10_25.shtml#e1020 > Sweeeeet!!! And not only that, but apparently... "Previously a __many__ section had to be the only sub-section in a section - now __many__ can appear alongside other sections and will only be used to validate sub-sections that don't have an explicit validation section." Does that same behavior apply to the scalar __many__ support? If so - double sweet. cheers, -David |
|
From: Michael F. <fuz...@vo...> - 2008-11-18 23:01:54
|
David Hostetler wrote: > On Tue, Nov 18, 2008 at 5:31 PM, Michael Foord > <fuz...@vo...> wrote: > >> That's a good idea. Let me check my time machine: >> >> http://www.voidspace.org.uk/python/weblog/arch_d7_2008_10_25.shtml#e1020 >> >> > > Sweeeeet!!! > > And not only that, but apparently... > > "Previously a __many__ section had to be the only sub-section in a > section - now __many__ can appear alongside other sections and will > only be used to validate sub-sections that don't have an explicit > validation section." > > Does that same behavior apply to the scalar __many__ support? If so > - double sweet. > It should work like that. Let me know if you have any problems. Michael > cheers, > > -David > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |