From 0a86745fbbb189dd9b51856db67e8c6af59cc7bd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 2 Aug 2013 13:53:14 -0700 Subject: [PATCH] emaint: fix exclusive action handling It broke in commit 42b0a6e898172c375d4d47c3346b25dac2333bf0. --- pym/portage/emaint/main.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/pym/portage/emaint/main.py b/pym/portage/emaint/main.py index 4b6d6669c..34763971f 100644 --- a/pym/portage/emaint/main.py +++ b/pym/portage/emaint/main.py @@ -1,4 +1,4 @@ -# Copyright 2005-2012 Gentoo Foundation +# Copyright 2005-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -6,7 +6,7 @@ from __future__ import print_function import sys import textwrap -from optparse import OptionParser, OptionValueError +from optparse import OptionParser import portage @@ -34,13 +34,6 @@ class OptionItem(object): self.type = opt.get('type', None) self.dest = opt.get('dest', None) - def _exclusive(self, option, *args, **kw): - """Generic check for the 2 default options - """ - if getattr(self.parser, var, ""): - raise OptionValueError("%s and %s are exclusive options" - % (getattr(self.parser, var), option)) - def usage(module_controller): _usage = "usage: emaint [options] COMMAND" @@ -160,19 +153,24 @@ def emaint_main(myargv): if args[0] not in module_names: parser.error("%s target is not a known target" % args[0]) - + check_opt = None func = status = long_action = None for opt in parser_options: if opt.long == '--check': # Default action - status = opt.status - func = opt.func - long_action = 'check' - elif opt.status and getattr(options, opt.long.lstrip("-"), False): + check_opt = opt + if opt.status and getattr(options, opt.long.lstrip("-"), False): + if long_action is not None: + parser.error("--%s and %s are exclusive options" % + (long_action, opt.long)) status = opt.status func = opt.func long_action = opt.long.lstrip('-') - break + + if long_action is None: + long_action = 'check' + func = check_opt.func + status = check_opt.status if args[0] == "all": tasks = [] -- 2.26.2