<commit_before>import sublime
import sublime_plugin
import textwrap

try: # Python 3
    from ...HaxeHelper import runcmd, show_quick_panel
except (ValueError): # Python 2
    from HaxeHelper import runcmd, show_quick_panel

print("HAXE : haxelib search ")

class HaxelibListLibs( sublime_plugin.WindowCommand ):
    def run(self):
        out,err = runcmd(["haxelib" , "search"], " \n \n \n");
        lines = out.splitlines()
        
        #remove the initial prompt
        lines[0] = lines[0].replace("Search word : ","")

        #sort alphabetically
        lines.sort(key=str.lower)

        #store for later
        self.libs = lines

        #show list
        show_quick_panel(self.window,lines,self.on_lib_select)


    def on_lib_select(self, index):
        if(index < 1):
            return

        name = self.libs[index]
        self.selected = name

        menu = []
        menu.append( ["Info", "haxelib info " + name] ) 
        menu.append( ["Install", "haxelib install " + name] )

        show_quick_panel(self.window, menu, self.on_action_selected)

    def on_action_selected(self, index):
        if(index < 0):<commit_msg>Sublime Text 2 / Python 2 support fixes<commit_after>import sublime
import sublime_plugin
import textwrap

try: # Python 3
    from ...HaxeHelper import runcmd, show_quick_panel
except (ValueError): # Python 2
    from HaxeHelper import runcmd, show_quick_panel

print("HAXE : haxelib search ")

class HaxelibListLibs( sublime_plugin.WindowCommand ):
    def run(self):
        out,err = runcmd(["haxelib" , "search"], " \n \n \n");
        lines = out.splitlines()
        
        #remove the initial prompt
        lines[0] = lines[0].replace("Search word : ","")

        #sort alphabetically
        lines = sorted( lines, cmp=lambda x,y: cmp(x.lower(), y.lower()) )

        #store for later
        self.libs = lines

        #show list
        show_quick_panel(self.window,lines,self.on_lib_select)


    def on_lib_select(self, index):
        if(index < 1):
            return

        name = self.libs[index]
        self.selected = name

        menu = []
        menu.append( ["Info", "haxelib info " + name] ) 
        menu.append( ["Install", "haxelib install " + name] )

        show_quick_panel(self.window, menu, self.on_action_selected)

    def on_action_selected(self, index):
        if(index < 0):
{'fraction_non_alphanumeric': 0.11621052631578947, 'fraction_numerical': 0.005894736842105263, 'mean_word_length': 2.5304606240713223, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1672211', 'n_tokens_mistral': 789, 'n_tokens_neox': 739, 'n_words': 183}