<commit_before># -*- coding: utf-8 -*-

from pyfiglet import Figlet
from stdPlugin import stdPlugin

class figlet(stdPlugin):
    u'''Écrit en mode figlet, qui a pour principal intérêt de flooder un canal.'''

    events = {'pubmsg': {'priority': 4, 'exclusive': True, 'command_namespace': 'figlet'}}

    def on_cmd(self, serv, ev, command, args, helper):
        u'''%(namespace)s <text> : écrit le texte donné en figlet. Ne gère que les caractères ASCII.'''
        f = Figlet()
        args.insert(0, command)
        message = ' '.join(args)
        for line in f.renderText(message).split('\n'):
            line = line.rstrip() # remove trailing spaces
            if line: # do not print empty lines
                serv.privmsg(helper['target'], line)<commit_msg>Figlet: limit line-width<commit_after># -*- coding: utf-8 -*-

from pyfiglet import Figlet
from stdPlugin import stdPlugin

class figlet(stdPlugin):
    u'''Écrit en mode figlet, qui a pour principal intérêt de flooder un canal.'''

    events = {'pubmsg': {'priority': 4, 'exclusive': True, 'command_namespace': 'figlet'}}
    width = 80 # max nb of characters per line

    def on_cmd(self, serv, ev, command, args, helper):
        u'''%(namespace)s <text> : écrit le texte donné en figlet. Ne gère que les caractères ASCII.'''
        f = Figlet()
        args.insert(0, command)
        message = ' '.join(args)
        figlet_msg = {}
        figlet_width = 0
        for c in message:
            figlet_c = f.renderText(c).split('\n')
            added_width = max(len(fc) for fc in figlet_c)
            # adding this character will make a too long line
            if figlet_width + added_width > self.width:
                # flush figlet message
                self.privfigletmsg(serv, helper['target'], figlet_msg)
                figlet_msg = {}
                figlet_width = 0
            # adding the character
            l = 0
            for fc in figlet_c:
                figlet_msg[l] = figlet_msg.get(l, '') + fc
                l += 1
            figlet_width += added_width
        # flush figlet message
        self.privfigletmsg(serv, helper['target'], figlet_msg)


    def privfigletmsg(self, serv, target, figletmsg):
        """
        Send the figlet message, removing blank lines
        """
        for l in xrange(7): # Figlet returns a 7-line message
            msg = figletmsg[l].rstrip() # remove trailing spaces
            if msg: # do not print empty lines
                serv.privmsg(target, msg)
{'fraction_non_alphanumeric': 0.11287758346581876, 'fraction_numerical': 0.005564387917329093, 'mean_word_length': 2.2186700767263425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4466172', 'n_tokens_mistral': 765, 'n_tokens_neox': 738, 'n_words': 243}