summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Options.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-16 09:02:23 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-16 09:02:23 -0400
commit8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b (patch)
tree5c45b7410cb005945027a7f0c9afaaea13199d39 /src/lib/Bcfg2/Options.py
parentd221337beaaafd7ce71717da64e4c9d91babd712 (diff)
downloadbcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.tar.gz
bcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.tar.bz2
bcfg2-8b163951cb19c1e70d90ce6f7f8b4a8a6e63da1b.zip
add_option properly adds an option to OptionParser after initial parsing
Diffstat (limited to 'src/lib/Bcfg2/Options.py')
-rw-r--r--src/lib/Bcfg2/Options.py12
1 files changed, 10 insertions, 2 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)