X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/7260cfbe90e7bf0a30b296a8196618c8558d08b9..2be7273ccdad115169ab0f8765f3fe66d0aeff47:/tools/cfgshell diff --git a/tools/cfgshell b/tools/cfgshell index acdf9fb..77afab9 100755 --- a/tools/cfgshell +++ b/tools/cfgshell @@ -53,6 +53,8 @@ class ConfigShell(cmd.Cmd): responsibility to know what they're doing. """ + # all do_/complete_* functions follow the same API + # pylint: disable-msg=W0613 prompt = "(/) " def __init__(self, cfg_file=None): @@ -91,7 +93,9 @@ class ConfigShell(cmd.Cmd): dirs = [] entries = [] if isinstance(obj, objects.ConfigObject): - for name in obj.__slots__: + # pylint: disable-msg=W0212 + # yes, we're using a protected member + for name in obj._all_slots(): child = getattr(obj, name, None) if isinstance(child, (list, dict, tuple, objects.ConfigObject)): dirs.append(name) @@ -177,7 +181,7 @@ class ConfigShell(cmd.Cmd): """ pointer = self.parents[-1] - dirs, entries = self._get_entries(pointer) + dirs, _ = self._get_entries(pointer) matches = [str(name) for name in dirs if name.startswith(text)] return matches @@ -202,7 +206,7 @@ class ConfigShell(cmd.Cmd): return False pointer = self.parents[-1] - dirs, entries = self._get_entries(pointer) + dirs, _ = self._get_entries(pointer) if line not in dirs: print "No such child" @@ -232,7 +236,7 @@ class ConfigShell(cmd.Cmd): """ pointer = self.parents[-1] - dirs, entries = self._get_entries(pointer) + _, entries = self._get_entries(pointer) matches = [name for name in entries if name.startswith(text)] return matches @@ -244,7 +248,7 @@ class ConfigShell(cmd.Cmd): """ pointer = self.parents[-1] - dirs, entries = self._get_entries(pointer) + _, entries = self._get_entries(pointer) if line not in entries: print "No such entry" return False @@ -309,14 +313,16 @@ class ConfigShell(cmd.Cmd): else: print "Invalid node name" - def do_EOF(self, line): + @staticmethod + def do_EOF(line): """Exit the application. """ print return True - def do_quit(self, line): + @staticmethod + def do_quit(line): """Exit the application. """ @@ -335,10 +341,9 @@ def ParseOptions(): In case of command line errors, it will show the usage and exit the program. - Returns: - (options, args), as returned by OptionParser.parse_args - """ + @return: a tuple (options, args), as returned by OptionParser.parse_args + """ parser = optparse.OptionParser() options, args = parser.parse_args() @@ -349,9 +354,8 @@ def ParseOptions(): def main(): """Application entry point. - This is just a wrapper over BootStrap, to handle our own exceptions. """ - options, args = ParseOptions() + _, args = ParseOptions() if args: cfg_file = args[0] else: