From c009b2686417fe983d9c23b37f4e5e0d7a5f9f3e Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Thu, 2 Feb 2012 08:44:00 +0100 Subject: [PATCH] fix crash when a command doesn't have a docstring --- weboob/tools/application/repl.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/weboob/tools/application/repl.py b/weboob/tools/application/repl.py index add1875e..3146f0ad 100644 --- a/weboob/tools/application/repl.py +++ b/weboob/tools/application/repl.py @@ -418,16 +418,18 @@ class ReplApplication(Cmd, ConsoleApplication): doc = getattr(self, 'do_' + command).__doc__ except AttributeError: return None - if doc: - doc = '\n'.join(line.strip() for line in doc.strip().split('\n')) - if not doc.startswith(command): - doc = '%s\n\n%s' % (command, doc) - if short: - doc = doc.split('\n')[0] - if not doc.startswith(command): - doc = command + if not doc: + return '%s' % command - return doc + doc = '\n'.join(line.strip() for line in doc.strip().split('\n')) + if not doc.startswith(command): + doc = '%s\n\n%s' % (command, doc) + if short: + doc = doc.split('\n')[0] + if not doc.startswith(command): + doc = command + + return doc def get_commands_doc(self): names = set(name for name in self.get_names() if name.startswith('do_'))