commit:     e166eb68e838389505f15426a2f0011dd95be342
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 13 03:40:49 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Mar 13 03:46:17 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e166eb68

portage/emaint/main.py: Fix a bug in the options parsing.

---
 pym/portage/emaint/main.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/portage/emaint/main.py b/pym/portage/emaint/main.py
index a03ffd7..6a17027 100644
--- a/pym/portage/emaint/main.py
+++ b/pym/portage/emaint/main.py
@@ -25,6 +25,9 @@ class OptionItem(object):
                """
                self.short = opt.get('short')
                self.long = opt.get('long')
+               # '-' are not allowed in python identifiers
+               # so store the sanitized target variable name
+               self.target = self.long[2:].replace('-','_')
                self.help = opt.get('help')
                self.status = opt.get('status')
                self.func = opt.get('func')
@@ -183,7 +186,7 @@ def emaint_main(myargv):
                if opt.long == '--check':
                        # Default action
                        check_opt = opt
-               if opt.status and getattr(options, opt.long.lstrip("-"), False):
+               if opt.status and getattr(options, opt.target, False):
                        if long_action is not None:
                                parser.error("--%s and %s are exclusive 
options" %
                                        (long_action, opt.long))
@@ -192,6 +195,7 @@ def emaint_main(myargv):
                        long_action = opt.long.lstrip('-')
 
        if long_action is None:
+               #print("DEBUG: long_action is None: setting to 'check'")
                long_action = 'check'
                func = check_opt.func
                status = check_opt.status
@@ -200,9 +204,9 @@ def emaint_main(myargv):
                tasks = []
                for m in module_names[1:]:
                        #print("DEBUG: module: %s, functions: " % (m, 
str(module_controller.get_functions(m))))
-                       if long_action in module_controller.get_functions(m):
+                       if func in module_controller.get_functions(m):
                                tasks.append(module_controller.get_class(m))
-       elif long_action in module_controller.get_functions(args[0]):
+       elif func in module_controller.get_functions(args[0]):
                tasks = [module_controller.get_class(args[0] )]
        else:
                portage.util.writemsg(

Reply via email to