summaryrefslogtreecommitdiffstats
path: root/gobject
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2007-11-06 08:55:56 +0000
committerJohan Dahlin <johan@src.gnome.org>2007-11-06 08:55:56 +0000
commit825d8de9a85f60a4d747e5cf4531c0ac761cfa13 (patch)
tree1ed13dd58a05ccc7fa8aeea36156349a26e86d06 /gobject
parent1b8078ba1c1c027a8c7f3b0e1a32dd03c6e26857 (diff)
downloadpygobject-825d8de9a85f60a4d747e5cf4531c0ac761cfa13.tar.gz
pygobject-825d8de9a85f60a4d747e5cf4531c0ac761cfa13.tar.xz
pygobject-825d8de9a85f60a4d747e5cf4531c0ac761cfa13.zip
Merge in values from all groups to the global option group. Slice up args
2007-11-06 Johan Dahlin <johan@gnome.org> * gobject/option.py (OptionParser.parse_args): Merge in values from all groups to the global option group. Slice up args so it doesn't return too much. * tests/test_option.py: Refactor to be unittesty, Add new tests to test what options returns. svn path=/trunk/; revision=717
Diffstat (limited to 'gobject')
-rw-r--r--gobject/option.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/gobject/option.py b/gobject/option.py
index 07a1c99..5930274 100644
--- a/gobject/option.py
+++ b/gobject/option.py
@@ -316,8 +316,10 @@ class OptionParser(optparse.OptionParser):
largs.extend(context.parse([sys.argv[0]] + rargs))
def parse_args(self, args=None, values=None):
+ old_args = args
try:
- return optparse.OptionParser.parse_args(self, args, values)
+ options, args = optparse.OptionParser.parse_args(
+ self, args, values)
except gobject.GError, error:
if error.domain != gobject.OPTION_ERROR:
raise
@@ -330,4 +332,11 @@ class OptionParser(optparse.OptionParser):
else:
raise
+ for group in self.option_groups:
+ for key, value in group.values.__dict__.items():
+ options.ensure_value(key, value)
+
+ args = args[2:-len(old_args)]
+ return options, args
+
make_option = Option