summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Options/Options.py
Commit message (Collapse)AuthorAgeFilesLines
* Options: Fixed non-path database name parsingChris St. Pierre2014-11-101-22/+41
| | | | | | | | | | | | The database name is sometimes a path (SQLite) and sometimes not (MySQL, PostgreSQL). This introduces a new Option type, RepositoryMacroOption, that expands <repository> macros without canonicalizing the path, so SQLite users can use <repository> in their settings but MySQL users' database name settings will not be destroyed by path canonicalization. The unfortunate downside is that SQLite users can't use ~ in their database name.
* Options: fix path canonicalization and file-like objectsChris St. Pierre2014-10-221-8/+3
| | | | | | This fixes canonicalizing PathOption values when the default value of a config file-only option is used. It also fixes PathOptions that get a file-like object instead of a filename string.
* Options: ensure <repository> macros are always fixed upChris St. Pierre2014-10-221-17/+42
| | | | | | | This fixes several cases in which <repository> macros would not be properly processed: options that are not added to the parser yet when early options are parsed; and config file options whose default value is used.
* testsuite: better debug capturing for options testsChris St. Pierre2014-10-221-2/+6
|
* testsuite: Added unit tests for new option parsingChris St. Pierre2014-10-221-25/+103
|
* Use setdefault instead of a conditionalMichael Fenn2014-07-151-3/+1
|
* Correctly handle config-file-only BooleanOptions which default to TrueMichael Fenn2014-07-141-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Bcfg2.Options.Parser._parse_config_options, if the "default" of the option (perhaps set by the config file) evaluates to True, then it runs the actions associated with the option. Otherwise, it just sets the option to the default directly with setattr. Since the default of a store_false action is True, the code will run argparse's _StoreFalseAction function. Well, _StoreFalseAction, is a subclass of _StoreConstAction where const=False. _StoreConstAction has a call method which looks like this: def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, self.const) So it completely ignores the value passed in and just sets the value of the option to const (i.e. False). Looking at fam_blocking {None: _StoreFalseAction(option_strings='fam_blocking', dest='fam_blocking', nargs=0, const=False, default=True, type=None, choices=None, help='FAM blocks on startup until all events are processed', metavar=None)} start phase 3 fam_blocking config val is True start phase 3 _parse_config_options: fam_blocking default is True _parse_config_options: calling argparse.<class 'argparse._StoreFalseAction'> with value True on fam_blocking _parse_config_options: after calling argparse.<class 'argparse._StoreFalseAction'> fam_blocking is False after _parse_config_options fam_blocking is False after phase 3 fam_blocking is False after phase 4 fam_blocking is False end of parser fam_blocking is False CLI init fam_blocking is False So how to fix it? Define a new Action? That seems like the most direct approach since the problem really is that _StoreFalseAction does what it says on the tin, it stores false no matter what. The new action BooleanOptionAction works like store_true and store_false, except that it stores the value that was passed in, or the default if there was no value passed in.
* pep8 fixesMichael Fenn2014-04-091-1/+0
|
* Options: Finalize actual value, not default valueChris St. Pierre2014-03-051-14/+18
| | | | This also fixes some extraneous calls in the option parsing loop.
* Options: set options debugging with environment variableChris St. Pierre2014-03-051-2/+24
|
* Options: Replace relative imports with absoluteChris St. Pierre2013-08-121-1/+1
|
* testsuite: fixed most pylint complaintsChris St. Pierre2013-08-091-3/+7
|
* Options: fix parsing of ComponentActions and other finalizable actionsChris St. Pierre2013-08-091-4/+3
|
* Options: wrote completely new option parserChris St. Pierre2013-06-271-0/+305