<commit_before>import json
import re
import Default.exec as default_exec

class ElmMakeCommand(default_exec.ExecCommand):
    '''Inspired by:
    http://www.sublimetext.com/forum/viewtopic.php?t=12028
    https://github.com/search?q=sublime+filename%3Aexec.py
    https://github.com/search?q=finish+ExecCommand+NOT+ProcessListener+extension%3Apy
    '''

    def run(self, error_format, **kwargs):
        self.error_format = error_format
        super(ElmMakeCommand, self).run(**kwargs)
        self.debug_text = ''

    def on_data(self, proc, json_data):
        result_str = json_data.decode(self.encoding)
        json_str, success_str = result_str.split('\n', 1)
        decode_error = lambda dict: self.format_error(**dict) if 'type' in dict else dict
        error_list = json.loads(json_str, object_hook=decode_error)
        error_list.append(success_str)
        error_str = '\n'.join(error_list)
        error_data = error_str.encode(self.encoding)
        super(ElmMakeCommand, self).on_data(proc, error_data)

    def format_error(self, type, file, region, overview, details, **kwargs):
        line = region['start']['line']
        column = region['start']['column']
        message = overview
        if details:
            message += '\n' + re.sub(r'(\n)+', r'\1', details)
        return self.error_format.format(**locals())
<commit_msg>Integrate Highlight Build Errors<commit_after>import json
import re

from importlib import import_module
try:
    default_exec = import_module('Highlight Build Errors').HighlightBuildErrors
except:
    import Default.exec as default_exec

class ElmMakeCommand(default_exec.ExecCommand):
    '''Inspired by:
    http://www.sublimetext.com/forum/viewtopic.php?t=12028
    https://github.com/search?q=sublime+filename%3Aexec.py
    https://github.com/search?q=finish+ExecCommand+NOT+ProcessListener+extension%3Apy
    https://github.com/bblanchon/SublimeText-HighlightBuildErrors/blob/master/HighlightBuildErrors.py
    '''

    def run(self, error_format, **kwargs):
        self.error_format = error_format
        super(ElmMakeCommand, self).run(**kwargs)
        self.debug_text = 'To highlight build errors : '
        try:
            if default_exec.g_show_errors:
                self.debug_text = ''
            else:
                self.debug_text += 'Open Command Pallete : Show Build Errors'
        except:
            self.debug_text += 'Install with Package Control : Highlight Build Errors'

    def on_data(self, proc, json_data):
        result_str = json_data.decode(self.encoding)
        json_str, success_str = result_str.split('\n', 1)
        decode_error = lambda dict: self.format_error(**dict) if 'type' in dict else dict
        error_list = json.loads(json_str, object_hook=decode_error)
        error_list.append(success_str)
        error_str = '\n'.join(error_list)
        error_data = error_str.encode(self.encoding)
        super(ElmMakeCommand, self).on_data(proc, error_data)

    def format_error(self, type, file, region, overview, details, **kwargs):
        line = region['start']['line']
        column = region['start']['column']
        message = overview
        if details:
            message += '\n' + re.sub(r'(\n)+', r'\1', details)
        return self.error_format.format(**locals())

{'fraction_non_alphanumeric': 0.12367061683378912, 'fraction_numerical': 0.0054694621695533276, 'mean_word_length': 3.2422680412371134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 2, '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': '4754835', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1000, 'n_words': 195}