From 29d50178d9405487b14b54344be7a79601f59b6f Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Wed, 30 Dec 2015 18:18:36 +0100 Subject: [PATCH] fix help display + probably fix issue #60 --- pupy/pupylib/PupyCmd.py | 8 +++++--- pupy/pupylib/PupyJob.py | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pupy/pupylib/PupyCmd.py b/pupy/pupylib/PupyCmd.py index 07dc661b..dd6a5faf 100644 --- a/pupy/pupylib/PupyCmd.py +++ b/pupy/pupylib/PupyCmd.py @@ -300,7 +300,7 @@ class PupyCmd(cmd.Cmd): try: doc=getattr(self, 'do_' + arg).__doc__ if doc: - self.stdout.write("%s\n"%str(doc)) + self.stdout.write("%s\n"%str(doc).strip()) return except AttributeError: pass @@ -327,7 +327,7 @@ class PupyCmd(cmd.Cmd): cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: - cmds_doc.append((cmd, getattr(self, name).__doc__)) + cmds_doc.append((cmd, getattr(self, name).__doc__.strip())) else: cmds_doc.append((cmd, "")) for name in [x for x in self.aliases.iterkeys()]: @@ -335,7 +335,9 @@ class PupyCmd(cmd.Cmd): self.stdout.write("%s\n"%str(self.doc_header)) for command,doc in cmds_doc: - self.stdout.write("- {:<10} {}\n".format(command, color(doc,'grey'))) + if doc is None: + doc="" + self.stdout.write("- {:<10} {}\n".format(command, color(doc.strip(),'grey'))) @staticmethod def format_log(msg): diff --git a/pupy/pupylib/PupyJob.py b/pupy/pupylib/PupyJob.py index c0e46e08..861ed8c5 100644 --- a/pupy/pupylib/PupyJob.py +++ b/pupy/pupylib/PupyJob.py @@ -134,7 +134,15 @@ class PupyJob(object): # raise RuntimeError("job %s has already been started !"%str(self)) for m in self.pupymodules: margs=m.arg_parser.parse_args(args) - comp, comp_exp= m.is_compatible() + res = m.is_compatible() + if type(res) is tuple: + comp, comp_exp=res + elif res is None: + comp=True + comp_exp="" + else: + comp=res + comp_exp="reason not precised" if not comp: m.error("Compatibility error : %s"%comp_exp) continue