Is there a shortcut method to skip the usual config boilerplate?

Asked by Stuart Metcalfe

For example, from the getting started docs, I need to do this:

    scp = SchemaConfigParser(MySchema())
    scp.read(['config.ini'])

    # support command-line integration
    op, opts, args = schemaconfigglue(scp)

    # validate the config (after taking into account any command-line
    # provided options
    is_valid, reasons = scp.is_valid(report=True)
ead the configuration files
    if not is_valid:
        op.error(reasons[0])

It would be great if I could just do:

MySchema.get_config(['config.ini'], cli-override=True)

Question information

Language:
English Edit question
Status:
Answered
For:
configglue Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Ricardo Kirkner (ricardokirkner) said :
#2

With the latest configglue, you can just do

glue = configglue(MySchema, ['config.ini'])

This will read the configuration files and validate the configuration by default.

Given your suggestion we might look into changing validation to be optional.

Thanks,
Ricardo

Revision history for this message
Ricardo Kirkner (ricardokirkner) said :
#3

With the latest configglue, you can just do

glue = configglue(MySchema, ['config.ini'])

This will read the configuration files and validate the configuration by default.

Given your suggestion we might look into changing validation to be optional.

Thanks,
Ricardo

Can you help with this problem?

Provide an answer of your own, or ask Stuart Metcalfe for more information if necessary.

To post a message you must log in.