diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-16 09:02:23 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-16 09:02:23 -0400 |
commit | 8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b (patch) | |
tree | 5c45b7410cb005945027a7f0c9afaaea13199d39 | |
parent | d221337beaaafd7ce71717da64e4c9d91babd712 (diff) | |
download | bcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.tar.gz bcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.tar.bz2 bcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.zip |
add_option properly adds an option to OptionParser after initial parsing
-rw-r--r-- | src/lib/Bcfg2/Options.py | 12 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index 2038af3bb..788f67aab 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -1,10 +1,11 @@ """Option parsing library for utilities.""" -import getopt import re import os import sys +import copy import shlex +import getopt import Bcfg2.Client.Tools # Compatibility imports from Bcfg2.Bcfg2Py3k import ConfigParser @@ -425,7 +426,7 @@ class OptionParser(OptionSet): self.Bootstrap = OptionSet([('configfile', CFILE)], quiet=True) self.Bootstrap.parse(sys.argv[1:], do_getopt=False) OptionSet.__init__(self, args, configfile=self.Bootstrap['configfile']) - self.optinfo = args + self.optinfo = copy.copy(args) def HandleEvent(self, event): if 'configfile' not in self or not isinstance(self['configfile'], str): @@ -451,3 +452,10 @@ class OptionParser(OptionSet): self.do_getopt = do_getopt OptionSet.parse(self, self.argv, do_getopt=self.do_getopt) + def add_option(self, name, opt): + self[name] = opt + self.optinfo[name] = opt + + def update(self, optdict): + dict.update(self, optdict) + self.optinfo.update(optdict) diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py index 5d55f3cbe..500c1e394 100644 --- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py @@ -385,7 +385,7 @@ class Cfg(Bcfg2.Server.Plugin.GroupSpool, SETUP = core.setup if 'validate' not in SETUP: - SETUP['validate'] = Bcfg2.Options.CFG_VALIDATION + SETUP.add_option('validate', Bcfg2.Options.CFG_VALIDATION) SETUP.reparse() def AcceptChoices(self, entry, metadata): |