← Back to team overview

configglue team mailing list archive

Re: [Bug 690670] [NEW] Please provide a way to validate arbitrarily named sections

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/16/2010 12:05 PM, James Westby wrote:
> On Thu, 16 Dec 2010 10:59:53 -0000, Ricardo Kirkner <690670@xxxxxxxxxxxxxxxxxx> wrote:
>> Hi James,
> 
>> thank you for your interest in configglue. Right now, what you ask is
>> not supported. However, if you give me some time I may be able to
>> implement something for this use case.
> 
> Great, thanks.
> 
>> On 12/15/2010 11:36 AM, James Westby wrote:
>>> """
>>> [hwpack]
>>> name = foo
>>> architectures = bar
>>>
>>> [ubuntu]
>>> sources-entry=http://archive.ubuntu.com/
>>>
>>> [linaro]
>>> sources-entry=http://ppa.launchpad.net/linaro
>>> """
>>>
>>> where "hwpack" is always required, and the other sections are up to the
>>> user to choose.
> 
> 
>> Regarding the optional sections, the section names are dynamic, or are
>> they known beforehand? (ie, do we know all potential section names, or
>> anything can be a section?)
> 
> They are not known beforehand. The user can have as many as they like.
> 
> Basically I am trying to collapse something like
> 
>   "repos": {
>        "name1": {
>           "sources-entry": "foo"
>        },
>        "name2": {
>           "sources-entry": "bar"
>        }
>   }
> 
> in to ini. The repo names are for user identification, but there can be
> as many of them as they like. I wanted to leave room for future
> expansion with the ability to set options for each repo, which is why
> this isn't a more compact notation.

By looking at this, I just realized something. Configglue already
supports dictionaries of dictionaries, and it also supports not
validating a dictionary's keys. So what you could try out is

repos = DictConfigOption(
    item=DictConfigOption(
        spec={'sources-entry': StringConfigOption(),
    )
)

With this definition, your config would read

[hwpack]
name = foo
architectures = bar
repos = ubuntu
        linaro

[ubuntu]
sources-entry=http://archive.ubuntu.com/

[linaro]
sources-entry=http://ppa.launchpad.net/linaro


I hope this helps. Please let me know.

Regards,

Ricardo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0nVl0ACgkQaHF+Qaymu6fT7QCcDSfgk/37RfHQMywLThOBmtQd
1ZQAoJ/RTuhcHNbSc85KcaSPFPY8ebdr
=PZW3
-----END PGP SIGNATURE-----

-- 
You received this bug notification because you are a member of
Configglue developers, which is the registrant for configglue.
https://bugs.launchpad.net/bugs/690670

Title:
  Please provide a way to validate arbitrarily named sections

Status in configglue:
  New

Bug description:
  Hi,

I have a use for configglue, but it doesn't yet meet all the criteria.

I have a config file that looks like

"""
[hwpack]
name = foo
architectures = bar

[ubuntu]
sources-entry=http://archive.ubuntu.com/

[linaro]
sources-entry=http://ppa.launchpad.net/linaro
"""

where "hwpack" is always required, and the other sections are up to the user to choose.

Therefore I want to be able to validate this. I can deal with the "hwpack" section fine, but
I can't currently validate the other sections. I would like to be able to define an "other"
validator, that is used to validate any section not explicitly named.

Michael said that ConfigObj can do this with __many__.

I don't know how this would link with the command line, but I don't have a requirement to
override these sections from the command line at this time.

Thanks,

James





References