<commit_before>import sublime
import sublime_plugin
import os
import subprocess
import json

class Helper(sublime_plugin.WindowCommand):
    def foo(self):
        return

    def bundle_op_is_visible(self, dirs):
        if len(dirs) == 0:
            return False
        else:
            return self.dir_is_aura(dirs[0])

    def file_op_is_visible(self, dirs):
        return self.parent_dir_is_aura(dirs[0])

    def dir_is_aura(self, working_dir):
        return os.path.basename(working_dir) == "aura"

    def parent_dir_is_aura(self, working_dir):
        return os.path.basename(os.path.dirname(working_dir)) == "aura"

    def is_bundle_type(self, working_dir, comp_type):
        files = os.listdir(working_dir[0])
        for filename in files:
            fname, fext = os.path.splitext(filename)
            if (fext == "." + comp_type):
                return True
        return False

    def has_this_file(self, working_dir, filename):
        return os.path.exists(os.path.join(working_dir, filename))

    def do_login(self, username, password):
        self.window.run_command(
            'exec',
            {'cmd': ["force", "login", "-u", username, "-p", password]})
        return

    def do_aura_query(self):
        return

    def do_fetch(self, bundle, adir):
        os.chdir(adir)
        if (bundle == 'all'):
            self.window.run_command(
                'exec',
                {'cmd': ["force", "fetch", "-t", "aura", "-d", adir],
                'working_dir': adir})
        else:
            self.window.run_command(
                'exec',
                {'cmd': ["force", "fetch", "-t", "aura", "-m", bundle, "-d", adir],
                'working_dir': adir})

        return

    def open_selected_bundle(self, index):
        if (index == 0):
            self.do_fetch("all", self.window.folders()[0])
        else:
            self.do_fetch(self.messages[index][2], self.window.folders()[0])
        return

    def show_bundle_list(self):
        self.messages = []
        p = subprocess.Popen(["force", "query", "Select Id, DeveloperName, MasterLabel, Description From AuraDefinitionBundle", "--format:json"], stdout=subprocess.PIPE)
        result = p.communicate()[0]
        try:
            m = json.loads(result.decode("utf-8)"))
            self.messages.append(["All Bundles", "*", "Every Bundle", "All the lightning bundles in your org!"])
            for mm in m:
                x = [mm['MasterLabel'], mm['Id'], mm["DeveloperName"], mm["Description"]]
                self.messages.append(x)

            self.window = sublime.active_window()
            self.window.show_quick_panel(self.messages, self.open_selected_bundle, sublime.MONOSPACE_FONT)
        except:
            return
            
    def make_bundle_file(self, file_name, extension, snippet, dirs):
        working_dir = dirs[0]
        os.chdir(working_dir)
        if extension == "cmp" or extension == "app" or extension == "evt":
            fn, ex = os.path.splitext(file_name)
            os.mkdir(os.path.join(working_dir, file_name))
            os.chdir(fn)
            working_dir = os.getcwd()

        app = open(file_name + "." + extension, "wb")
        if int(sublime.version()) >= 3000:
            app.write(bytes(snippet, 'UTF-8'))
        else:  # To support Sublime Text 2
            app.write(bytes(snippet))

        app.close()
        filename = os.path.join(working_dir, file_name + "." + extension)
        self.window.open_file(filename)
        cmd = '-f=' + filename
        self.window.run_command(<commit_msg>change fetch flag to match new version<commit_after>import sublime
import sublime_plugin
import os
import subprocess
import json

class Helper(sublime_plugin.WindowCommand):
    def foo(self):
        return

    def bundle_op_is_visible(self, dirs):
        if len(dirs) == 0:
            return False
        else:
            return self.dir_is_aura(dirs[0])

    def file_op_is_visible(self, dirs):
        return self.parent_dir_is_aura(dirs[0])

    def dir_is_aura(self, working_dir):
        return os.path.basename(working_dir) == "aura"

    def parent_dir_is_aura(self, working_dir):
        return os.path.basename(os.path.dirname(working_dir)) == "aura"

    def is_bundle_type(self, working_dir, comp_type):
        files = os.listdir(working_dir[0])
        for filename in files:
            fname, fext = os.path.splitext(filename)
            if (fext == "." + comp_type):
                return True
        return False

    def has_this_file(self, working_dir, filename):
        return os.path.exists(os.path.join(working_dir, filename))

    def do_login(self, username, password):
        self.window.run_command(
            'exec',
            {'cmd': ["force", "login", "-u", username, "-p", password]})
        return

    def do_aura_query(self):
        return

    def do_fetch(self, bundle, adir):
        os.chdir(adir)
        if (bundle == 'all'):
            self.window.run_command(
                'exec',
                {'cmd': ["force", "fetch", "-t", "aura", "-d", adir],
                'working_dir': adir})
        else:
            self.window.run_command(
                'exec',
                {'cmd': ["force", "fetch", "-t", "aura", "-n", bundle, "-d", adir],
                'working_dir': adir})

        return

    def open_selected_bundle(self, index):
        if (index == 0):
            self.do_fetch("all", self.window.folders()[0])
        else:
            self.do_fetch(self.messages[index][2], self.window.folders()[0])
        return

    def show_bundle_list(self):
        self.messages = []
        p = subprocess.Popen(["force", "query", "Select Id, DeveloperName, MasterLabel, Description From AuraDefinitionBundle", "--format:json"], stdout=subprocess.PIPE)
        result = p.communicate()[0]
        try:
            m = json.loads(result.decode("utf-8)"))
            self.messages.append(["All Bundles", "*", "Every Bundle", "All the lightning bundles in your org!"])
            for mm in m:
                x = [mm['MasterLabel'], mm['Id'], mm["DeveloperName"], mm["Description"]]
                self.messages.append(x)

            self.window = sublime.active_window()
            self.window.show_quick_panel(self.messages, self.open_selected_bundle, sublime.MONOSPACE_FONT)
        except:
            return

    def make_bundle_file(self, file_name, extension, snippet, dirs):
        working_dir = dirs[0]
        os.chdir(working_dir)
        if extension == "cmp" or extension == "app" or extension == "evt":
            fn, ex = os.path.splitext(file_name)
            os.mkdir(os.path.join(working_dir, file_name))
            os.chdir(fn)
            working_dir = os.getcwd()

        app = open(file_name + "." + extension, "wb")
        if int(sublime.version()) >= 3000:
            app.write(bytes(snippet, 'UTF-8'))
        else:  # To support Sublime Text 2
            app.write(bytes(snippet))

        app.close()
        filename = os.path.join(working_dir, file_name + "." + extension)
        self.window.open_file(filename)
        cmd = '-f=' + filename
        self.window.run_command(
{'fraction_non_alphanumeric': 0.1364207002371321, 'fraction_numerical': 0.004742641930534245, 'mean_word_length': 2.190921228304406, 'pattern_counts': {'":': 2, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '572327', 'n_tokens_mistral': 2284, 'n_tokens_neox': 2177, 'n_words': 471}