<commit_before>import sublime, sublime_plugin

is_sublime_text_3 = int(sublime.version()) >= 3000

if is_sublime_text_3:
    from .progress_notifier import ProgressNotifier
else:
    from progress_notifier import ProgressNotifier

# A base for each command
class BaseCommand(sublime_plugin.WindowCommand):
    def run(self, task_name = None, silent = False):
        self.setup_data_from_settings()
        self.task_name = task_name
        self.silent = silent
        self.work()

    def setup_data_from_settings(self):
        self.settings = sublime.load_settings("Gulp.sublime-settings")
        self.results_in_new_tab = self.settings.get("results_in_new_tab", False)

    # Main method, override
    def work(self):
        pass

    # Panels and message
    def show_quick_panel(self, items, on_done = None, font = sublime.MONOSPACE_FONT):
        self.defer_sync(lambda: self.window.show_quick_panel(items, on_done, font))

    def show_input_panel(self, caption, initial_text = "", on_done = None, on_change = None, on_cancel = None):
        self.window.show_input_panel(caption, initial_text, on_done, on_change, on_cancel)

    def status_message(self, text):
        sublime.status_message("%s: %s" % (self.package_name, text))

    def error_message(self, text):
        sublime.error_message("%s: %s" % (self.package_name, text))

    # Output view
    def show_output_panel(self, text):
        if self.silent: return
        
        if self.results_in_new_tab:
            self.output_view = self.window.open_file("Gulp Results")
            self.output_view.set_scratch(True)
            self.scroll_to_end = False
        else:
            self.output_view = self.window.get_output_panel("gulp_output")
            self.scroll_to_end = True
            self.show_panel()
            
        self.append_to_output_view(text)

    def append_to_output_view_in_main_thread(self, text):
        self.defer_sync(lambda: self.append_to_output_view(text))

    def append_to_output_view(self, text):
        if not self.silent:
            self._insert(self.output_view, CrossPlaformCodecs.decode(text))

    def _insert(self, view, content):
        if self.results_in_new_tab and self.output_view.is_loading():
            self.set_timeout(lambda: self._insert(view, content), 10)
        else:
            view.set_read_only(False)
            view.run_command("view_insert", { "size": view.size(), "content": content })
            position = (view.size(), view.size()) if self.scroll_to_end else (0, 0)<commit_msg>Let the user know the task is running<commit_after>import sublime, sublime_plugin

is_sublime_text_3 = int(sublime.version()) >= 3000

if is_sublime_text_3:
    from .progress_notifier import ProgressNotifier
else:
    from progress_notifier import ProgressNotifier

# A base for each command
class BaseCommand(sublime_plugin.WindowCommand):
    def run(self, task_name = None, silent = False):
        self.setup_data_from_settings()
        self.task_name = task_name
        self.silent = silent
        self.work()

    def setup_data_from_settings(self):
        self.settings = sublime.load_settings("Gulp.sublime-settings")
        self.results_in_new_tab = self.settings.get("results_in_new_tab", False)

    # Main method, override
    def work(self):
        pass

    # Panels and message
    def show_quick_panel(self, items, on_done = None, font = sublime.MONOSPACE_FONT):
        self.defer_sync(lambda: self.window.show_quick_panel(items, on_done, font))

    def show_input_panel(self, caption, initial_text = "", on_done = None, on_change = None, on_cancel = None):
        self.window.show_input_panel(caption, initial_text, on_done, on_change, on_cancel)

    def status_message(self, text):
        sublime.status_message("%s: %s" % (self.package_name, text))

    def error_message(self, text):
        sublime.error_message("%s: %s" % (self.package_name, text))

    # Output view
    def show_output_panel(self, text):
        if self.silent:
            self.status_message(text)
            return
        
        if self.results_in_new_tab:
            self.output_view = self.window.open_file("Gulp Results")
            self.output_view.set_scratch(True)
            self.scroll_to_end = False
        else:
            self.output_view = self.window.get_output_panel("gulp_output")
            self.scroll_to_end = True
            self.show_panel()
            
        self.append_to_output_view(text)

    def append_to_output_view_in_main_thread(self, text):
        self.defer_sync(lambda: self.append_to_output_view(text))

    def append_to_output_view(self, text):
        if not self.silent:
            self._insert(self.output_view, CrossPlaformCodecs.decode(text))

    def _insert(self, view, content):
        if self.results_in_new_tab and self.output_view.is_loading():
            self.set_timeout(lambda: self._insert(view, content), 10)
        else:
            view.set_read_only(False)
            view.run_command("view_insert", { "size": view.size(), "content": content })
            position = (view.size(), view.size()) if self.scroll_to_end else (0, 0)
{'fraction_non_alphanumeric': 0.10163233579479207, 'fraction_numerical': 0.00388651379712398, 'mean_word_length': 3.0400313971742543, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, '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': '4176718', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1618, 'n_words': 317}