openmicroscopy/yaclifw — pull request #5 by manics (2014-07-03 16:32:35+00:00)
Title: argparse configuration file

See also ome/omego#41
This is an attempt to let configuration provide defaults for argparse comand line options, using Python's `ConfigFileParser`

Main points:
* Config file values are automatically cast if a `type` is specified in `add_argument`
* Limited support for the `action` parameter of `add_argument`: `store_true`/`store_false`/`count` will result in a config value being automatically cast to `bool`/`bool`/`int`, other actions are untested
* I've tried to avoid referencing any private underscore classes from `argparse` (though this makes things more complicated)
* Parsing has to be done in two steps:
1. Look for any config file arguments, and parse those files
2. Parse the remaining arguments
* Parsers/subparsers can reference one or more sections from ConfigFileParser
* Multiple sections can be specified and merged (e.g. you could have a defaults section overriden later)
* Shouldn't require significant changes to users of this class.
* Note added to README.rst

TODO: omego PR to demonstrate usage.