def _generate_command_words(self, commands, msg):
        """
            Generate an array of arrays, of command words
            Length of each array, is max irc messages length
        """
        def _size(alist):
            size = 0
            for words in alist:
                for word in words:
                    size += len(word) + 2  # Room for formating
            return size

            #Smarter Line Wrap
        messages = [['Command List:']]  # List of commands to send
        prefix_len = len('PRVMSG %s :' % msg.nick)
        for word in sorted(commands):
            show = False
            event_handler = self.get(word)
            if event_handler:
                for observer in event_handler.observers():
                    if observer.__doc__:
                        show = True
                        break
            if show:  # Hidden Commands Stay Hidden
                if _size(messages[-1]) + len(word) + prefix_len <= 510:
                    messages[-1].append(word)
                else:
                    messages.append([word])
        return messages
dataset/ETHPy150Open facebook/pyaib/pyaib/triggers.py/Triggers._generate_command_words/original