From 9ebd09d174b45c7414a0486d5abff671574689ca Mon Sep 17 00:00:00 2001 From: Huang Hao Date: Mon, 18 Feb 2013 10:52:25 +0800 Subject: 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 --- tools/mic | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'tools') 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): -- cgit v1.2.3