Move function optparser_setup out of class MicCmd
authorHuang Hao <hao.h.huang@intel.com>
Mon, 18 Feb 2013 02:52:25 +0000 (10:52 +0800)
committerHuang Hao <hao.h.huang@intel.com>
Mon, 18 Feb 2013 07:18:24 +0000 (15:18 +0800)
Found this problem by pylint. Decorator optparser_setup is not a
instance/class/static method of MicCmd, so move it out.

Also fix wrong indent.

Change-Id: I0315951134360fa6081b904e6323e57c16b7ef9f

tools/mic

index e45b1ec..02a96df 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -22,6 +22,15 @@ from mic.conf import configmgr
 from mic.plugin import pluginmgr
 from mic.__version__ import VERSION
 
+
+def optparser_setup(func):
+    """Setup optparser for a function"""
+    if not hasattr(func, "optparser"):
+        func.optparser = cmdln.SubCmdOptionParser()
+        func.optparser.disable_interspersed_args()
+    return func
+
+
 class MicCmd(cmdln.Cmdln):
     """
     Usage: mic SUBCOMMAND [OPTS] [ARGS...]
@@ -69,13 +78,6 @@ class MicCmd(cmdln.Cmdln):
 
         self.print_version()
 
-    def optparser_setup(func):
-        """Setup optparser for a function"""
-        if not hasattr(func, "optparser"):
-            func.optparser = cmdln.SubCmdOptionParser()
-            func.optparser.disable_interspersed_args()
-        return func
-
     def help_create(self):
         cr = creator.Creator()
         cr.optparser = cr.get_optparser()
@@ -139,14 +141,14 @@ class MicCmd(cmdln.Cmdln):
         srcimager = None
         destimager = None
         for iname, icls in pluginmgr.get_plugins('imager').iteritems():
-           if iname == srcformat and hasattr(icls, "do_unpack"):
-               srcimager = icls
-           if iname == destformat and hasattr(icls, "do_pack"):
-               destimager = icls
+            if iname == srcformat and hasattr(icls, "do_unpack"):
+                srcimager = icls
+            if iname == destformat and hasattr(icls, "do_pack"):
+                destimager = icls
 
         if (srcimager and destimager) is None:
-           raise errors.CreatorError("Can't convert from %s to %s" \
-                                     % (srcformat, destformat))
+            raise errors.CreatorError("Can't convert from %s to %s" \
+                                      % (srcformat, destformat))
 
         else:
             maptab = {
@@ -189,7 +191,7 @@ class MicCmd(cmdln.Cmdln):
             if hasattr(handler, "optparser"):
                 handler.optparser.print_help()
             return 1
-        
+
         targetimage = args[0]
 
         if not os.path.exists(targetimage):