<commit_before>from gtk import Window, VBox, HBox, Entry, Button
import gtk
import dbHandler as fileDB
import dbManager as db
import Utils

class helloworld:
    def helloworld(self, wiget, data=None):
        print("Hello world from mango brain!")

    def delete_event(self, widget, event, data=None):
        print("Delete event")
        return False

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def addNewItem(self, widget, data=None):
        db.addItem(str(self.addText.get_text()))
        fileDB.Store(db.getDB())

    def __init__(self):
        self.window = Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Mango Mapper")
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(10)
        self.window.show()

        verticalbox = VBox(False, 0)
        self.window.add(verticalbox)
        verticalbox.show()




        # create the buttom row, housing add task funcs
        addNewBar = HBox(False, 0)
        verticalbox.add(addNewBar)
        addNewBar.show()

        # text field
        self.addText = Entry(max=0)
        addNewBar.add(self.addText)
        self.addText.insert_text("Write new task here", position=0)
        self.addText.show()

        addNewButton = Button("Add Item")
        addNewButton.show()
        addNewButton.connect("clicked", self.addNewItem, None)
        addNewBar.add(addNewButton)


    def main(self):
        gtk.main()


if __name__ == "__main__":
    Utils.initLogger(True)
    db.setDB(fileDB.Load())
    hello = helloworld()<commit_msg>refactore code to have shorter functions.<commit_after>from gtk import Window, VBox, HBox, Entry, Button
import gtk
import dbHandler as fileDB
import dbManager as db
import Utils

class helloworld:
    def helloworld(self, wiget, data=None):
        print("Hello world from mango brain!")

    def delete_event(self, widget, event, data=None):
        print("Delete event")
        return False

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def addNewItem(self, widget, data=None):
        db.addItem(str(self.addText.get_text()))
        fileDB.Store(db.getDB())


    def createAddBar(self):
        # text field
        self.addText = Entry(max=0)
        self.addText.insert_text("Write new task here", position=0)
        self.addText.show()

        addNewButton = Button("Add Item")
        addNewButton.show()
        addNewButton.connect("clicked", self.addNewItem, None)


        #build structs
        addNewBar = HBox(False, 0)
        addNewBar.add(self.addText)
        addNewBar.add(addNewButton)
        addNewBar.show()
        return addNewBar

    def __init__(self):

        addNewBar = self.createAddBar()

        verticalbox = VBox(False, 0)
        verticalbox.add(addNewBar)
        verticalbox.show()


        self.window = Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Mango Mapper")
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(10)
        self.window.show()
        self.window.add(verticalbox)


    def main(self):
        gtk.main()


if __name__ == "__main__":
    Utils.initLogger(True)
    db.setDB(fileDB.Load())
    hello = helloworld()
{'fraction_non_alphanumeric': 0.11233611442193087, 'fraction_numerical': 0.003575685339690107, 'mean_word_length': 2.6728665207877462, 'pattern_counts': {'":': 2, '<': 3, '<?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': '266751', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1038, 'n_words': 224}