summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHuang Hao <hao.h.huang@intel.com>2013-02-18 10:52:25 +0800
committerHuang Hao <hao.h.huang@intel.com>2013-02-18 15:18:24 +0800
commit9ebd09d174b45c7414a0486d5abff671574689ca (patch)
treee7b15a969f61b1dee11d40b49768c1516629a1a6 /tools
parentc41649172f3cd153edc5edcfe8133cde143207d7 (diff)
downloadmic-9ebd09d174b45c7414a0486d5abff671574689ca.tar.gz
mic-9ebd09d174b45c7414a0486d5abff671574689ca.tar.bz2
mic-9ebd09d174b45c7414a0486d5abff671574689ca.zip
Move function optparser_setup out of class MicCmd
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
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mic30
1 files changed, 16 insertions, 14 deletions
diff --git a/tools/mic b/tools/mic
index e45b1ec..02a96df 100755
--- 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):