<commit_before>import re

from events import Event, get_timestamp, ACCEPTED, FINISHED

# input/output

class ServerInput(Event):
    """Send data to the server's stdin. In plugins, a shortcut
    is available: self.send("say hello")"""
    
    requires = ('line',)
    parse_colors = False
    def setup(self):
        if self.parse_colors:
            self.line = re.sub("\&([0-9a-fklmnor])", u"\u00a7\\1", self.line, flags=re.IGNORECASE)

class ServerOutput(Event):
    """Issued when the server gives us a line on stdout. Note
    that to handle this, you must specify both the 'level'
    (e.g. INFO or SEVERE) and a regex pattern to match"""
    
    contains = ('line', 'time', 'level', 'data')
    requires = ('line',)
    requires_predicate = ('pattern',)
    
    data = None
    time = None
    
    
    def setup(self):
        m = re.match(r'(\d{4}-\d{2}-\d{2} |)(\d{2}:\d{2}:\d{2}) \[([A-Z]+)\] (.*)', self.line)
        if m:
            g = m.groups()
            self.time = g[0]+g[1]
            self.level= g[2]<commit_msg>events/server: fix FTB support<commit_after>import re

from events import Event, get_timestamp, ACCEPTED, FINISHED

# input/output

class ServerInput(Event):
    """Send data to the server's stdin. In plugins, a shortcut
    is available: self.send("say hello")"""
    
    requires = ('line',)
    parse_colors = False
    def setup(self):
        if self.parse_colors:
            self.line = re.sub("\&([0-9a-fklmnor])", u"\u00a7\\1", self.line, flags=re.IGNORECASE)

class ServerOutput(Event):
    """Issued when the server gives us a line on stdout. Note
    that to handle this, you must specify both the 'level'
    (e.g. INFO or SEVERE) and a regex pattern to match"""
    
    contains = ('line', 'time', 'level', 'data')
    requires = ('line',)
    requires_predicate = ('pattern',)
    
    data = None
    time = None
    
    
    def setup(self):
        m = re.match(r'(\d{4}-\d{2}-\d{2} |)(\d{2}:\d{2}:\d{2}) \[([A-Z]+)\] (?:\[Minecraft\] )?(.*)', self.line)
        if m:
            g = m.groups()
            self.time = g[0]+g[1]
            self.level= g[2]
{'fraction_non_alphanumeric': 0.17200754005655042, 'fraction_numerical': 0.01413760603204524, 'mean_word_length': 2.457654723127036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5475654', 'n_tokens_mistral': 751, 'n_tokens_neox': 735, 'n_words': 203}