<commit_before>import sys
import json
from PyQt4 import *

from inc.form1 import *

class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        self.accounts = list()

        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_mainWindow()
        self.ui.setupUi(self)
        
        self.ui.pushButtonAdd.clicked.connect(self.add)

        COLUMNS = 3
        self.ui.tableWidgetAccounts.setColumnCount(COLUMNS)
        self.ui.tableWidgetAccounts.setHorizontalHeaderLabels(["username", "hostname", "generate"])

        self.load_accounts_file()
        self.update_table()


    def add(self):
        username = self.ui.lineEditAddUsername.text()
        hostname = self.ui.lineEditAddHostname.text()
        print "username: ", username
        print "hostname: ", hostname
        print "TODO add"


    def load_accounts_file(self):
        with open("accounts.json", "r") as f:
            self.accounts = json.load(f)


    def update_table(self):
        self.ui.tableWidgetAccounts.setRowCount(len(self.accounts))

        for row, account in enumerate(self.accounts):
            widgetUsername = QtGui.QTableWidgetItem(account["username"])
            widgetHostname = QtGui.QTableWidgetItem(account["hostname"])
            widgetGenerate = QtGui.QTableWidgetItem("generate")

            self.ui.tableWidgetAccounts.setItem(row, 0, widgetUsername)
            self.ui.tableWidgetAccounts.setItem(row, 1, widgetHostname)
            self.ui.tableWidgetAccounts.setItem(row, 2, widgetGenerate)
            

<commit_msg>now possible to add accounts to the table<commit_after>import sys
import json
from PyQt4 import *

from inc.form1 import *

class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        self.accounts = list()

        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_mainWindow()
        self.ui.setupUi(self)
        
        self.ui.pushButtonAdd.clicked.connect(self.add)

        COLUMNS = 3
        self.ui.tableWidgetAccounts.setColumnCount(COLUMNS)
        self.ui.tableWidgetAccounts.setHorizontalHeaderLabels(["username", "hostname", "generate"])

        self.load_accounts_file()
        self.update_table()


    def add(self):
        username = self.ui.lineEditAddUsername.text()
        hostname = self.ui.lineEditAddHostname.text()

        newUser = dict()
        newUser["username"] = username
        newUser["hostname"] = hostname

        self.accounts.append(newUser)
        
        self.update_table()


    def load_accounts_file(self):
        with open("accounts.json", "r") as f:
            self.accounts = json.load(f)


    def update_table(self):
        self.ui.tableWidgetAccounts.setRowCount(len(self.accounts))

        for row, account in enumerate(self.accounts):
            widgetUsername = QtGui.QTableWidgetItem(account["username"])
            widgetHostname = QtGui.QTableWidgetItem(account["hostname"])
            widgetGenerate = QtGui.QTableWidgetItem("generate")

            self.ui.tableWidgetAccounts.setItem(row, 0, widgetUsername)
            self.ui.tableWidgetAccounts.setItem(row, 1, widgetHostname)
            self.ui.tableWidgetAccounts.setItem(row, 2, widgetGenerate)
            


{'fraction_non_alphanumeric': 0.10646858557722068, 'fraction_numerical': 0.003714020427112349, 'mean_word_length': 2.6979405034324944, 'pattern_counts': {'":': 0, '<': 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': '1413989', 'n_tokens_mistral': 983, 'n_tokens_neox': 953, 'n_words': 162}