def do_help(self, arg):
        'List available commands with "help" or detailed help with "help cmd".'

        if arg:
            # Don't provide help for non-exposed commands
            if arg not in self.commands+self.baseCommands:
                return self.sendData("%s" % str(self.nohelp % (arg,)))

            # XXX check arg syntax
            DOC = ''
            try:
                # Do we have any docstring ?
                doc = getattr(self, 'do_' + arg).__doc__
                if doc:
                    DOC += doc

                # Do we have any extended doc from options ?
                extended_doc = getattr(self, 'do_' + arg).__extended_doc__
                if extended_doc:
                    DOC += '\n'+extended_doc

            except Exception:
                if DOC == '':
                    return self.sendData("%s" % str(self.nohelp % (arg,)))

            return self.sendData("%s"%str(DOC))
        else:
            # Get commands first
            helpText = self.helpHeaders['commands']+'\n'+self.helpHeaders['ruler']*len(
                self.helpHeaders['commands'])
            for cmd in self.commands:
                helpText += "\n"
                helpText += '%s' % cmd.ljust(20)
                doc = getattr(self, 'do_' + cmd).__doc__
                if doc:
                    helpText += str(doc)
                else:
                    helpText += "%s" % str(self.nohelp % (cmd,))

            # Then get baseCommands
            helpText += '\n\n'+self.helpHeaders['baseCommands']+'\n'+self.helpHeaders['ruler']*len(
                self.helpHeaders['baseCommands'])
            for cmd in self.baseCommands:
                helpText += "\n"
                helpText += '%s' % cmd.ljust(20)
                doc = getattr(self, 'do_' + cmd).__doc__
                if doc:
                    helpText += str(doc)
                else:
                    helpText += "%s" % str((cmd,) % self.nohelp)

            return self.sendData(helpText)
dataset/ETHPy150Open jookies/jasmin/jasmin/protocols/cli/protocol.py/CmdProtocol.do_help/swapped operands of `%`