← Back to team overview

configglue team mailing list archive

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

 

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.

We then process this by reading the [hwpack] section to get the global
information, before looping over the other sections to read the repo
information.

So the point is that the section names aren't known in advance, rather
than there being multiple of them which have the same schema.

> >
> > 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.


> For the integration with the command line, ideally this will behave like
> any other section/option, ie.

> - --section_option=value

I'm not sure this would make much sense to the user, what would the help
for this be?

Thanks,

James

-- 
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





Follow ups

References