<commit_before>import sublime
import sublime_plugin
import json
import os.path as fs

PROJECT_NOT_FOUND_MSG = 'Valid elm-package.json NOT found for updating'
PROJECT_UPDATED_MSG = 'elm-package.json updated : {0} = {1}'

class ElmProjectCommand(sublime_plugin.TextCommand):

    def run(self, edit, prop_name=None, choices=None, caption=None):
        self.project = ElmProject(self.view.file_name())
        if not self.project.exists:
            return sublime.status_message(PROJECT_NOT_FOUND_MSG)
        window = self.view.window()
        if not prop_name:
            return window.open_file(self.project.json_path, sublime.TRANSIENT)
        self.prop_name = prop_name
        initial_value = getattr(self.project, prop_name)
        if not choices:
            return window.show_input_panel(caption, initial_value, self.on_finished, None, None)
        self.choices = choices
        if int(sublime.version()) < 3000:
            return window.show_quick_panel(choices, self.on_option)
        try:
            initial_index = [choice.lower() for choice in choices].index(initial_value.lower())
        except:
            initial_index = -1
        window.show_quick_panel(choices, self.on_option, selected_index=initial_index)

    def on_finished(self, value):
        setattr(self.project, self.prop_name, value)
        sublime.status_message(PROJECT_UPDATED_MSG.format(self.prop_name, value))

    def on_option(self, index):
        if index != -1:
            self.on_finished(self.choices[index].lower())

BUILD_KEY = ('sublime-build',)
MAIN_KEY = BUILD_KEY + ('main',)
OUTPUT_KEY = BUILD_KEY + ('output',)
OUTPUT_PATH_KEY = OUTPUT_KEY + ('path',)
OUTPUT_COMP_KEY = OUTPUT_KEY + ('components',)
OUTPUT_DIR_KEY = OUTPUT_COMP_KEY + ('dir',)
OUTPUT_NAME_KEY = OUTPUT_COMP_KEY + ('name',)
OUTPUT_EXT_KEY = OUTPUT_COMP_KEY + ('ext',)
<commit_msg>Disable project commands when missing config<commit_after>import sublime
import sublime_plugin
import json
import os.path as fs

PROJECT_NOT_FOUND_MSG = 'Valid elm-package.json NOT found for updating'
PROJECT_UPDATED_MSG = 'elm-package.json updated : {0} = {1}'

class ElmProjectCommand(sublime_plugin.TextCommand):

    def run(self, edit, prop_name=None, choices=None, caption=None):
        window = self.view.window()
        if not prop_name:
            return window.open_file(self.project.json_path, sublime.TRANSIENT)
        self.prop_name = prop_name
        initial_value = getattr(self.project, prop_name)
        if not choices:
            return window.show_input_panel(caption, initial_value, self.on_finished, None, None)
        self.choices = choices
        if int(sublime.version()) < 3000:
            return window.show_quick_panel(choices, self.on_option)
        try:
            initial_index = [choice.lower() for choice in choices].index(initial_value.lower())
        except:
            initial_index = -1
        window.show_quick_panel(choices, self.on_option, selected_index=initial_index)

    def is_enabled(self):
        self.project = ElmProject(self.view.file_name())
        return self.project.exists

    def on_finished(self, value):
        setattr(self.project, self.prop_name, value)
        sublime.status_message(PROJECT_UPDATED_MSG.format(self.prop_name, value))

    def on_option(self, index):
        if index != -1:
            self.on_finished(self.choices[index].lower())

BUILD_KEY = ('sublime-build',)
MAIN_KEY = BUILD_KEY + ('main',)
OUTPUT_KEY = BUILD_KEY + ('output',)
OUTPUT_PATH_KEY = OUTPUT_KEY + ('path',)
OUTPUT_COMP_KEY = OUTPUT_KEY + ('components',)
OUTPUT_DIR_KEY = OUTPUT_COMP_KEY + ('dir',)
OUTPUT_NAME_KEY = OUTPUT_COMP_KEY + ('name',)
OUTPUT_EXT_KEY = OUTPUT_COMP_KEY + ('ext',)

{'fraction_non_alphanumeric': 0.11018318965517242, 'fraction_numerical': 0.004310344827586207, 'mean_word_length': 3.5446756425948593, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6667441', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1190, 'n_words': 240}