<commit_before>
import os
from PySide import QtGui
from core.views.project.main_ui import Ui_ProjectWindow
from core.utility.collection import SettingsINI
from core.models.filetree import FileTreeModel
from core.views.settings import SettingsDialog
class ProjectMainWindow(QtGui.QMainWindow, Ui_ProjectWindow):
    def __init__(self, dirname: str, settings_ini: str):
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)

        self.SettingsDialog = SettingsDialog(filename=settings_ini)
        self.setWindowTitle(self.SettingsDialog.rootDirectoryLineEdit.text())
        self.connect_actions()
        self.connect_filetree()

    def connect_actions(self):
        self.actionPreferences.triggered.connect(self.open_settings_dialog)

    def connect_filetree(self):
        rootdir = self.SettingsDialog.rootDirectoryLineEdit.text()
        model = FileTreeModel(root_dir=rootdir)
        self.ProjectsTreeView.setModel(model)
        self.ProjectsTreeView.setRootIndex(model.index(rootdir))

    def connect_settings_dialog(self):
        self.SettingsDialog.cloudProviderComboBox.setVisible(False)
        self.SettingsDialog.cloudProviderLabel.setVisible(False)
        self.SettingsDialog.rootDirectoryLabel.setVisible(False)
        self.SettingsDialog.rootDirectoryLineEdit.setVisible(False)



    def open_settings_dialog(self):
        self.SettingsDialog.exec_()
<commit_msg>Integrated pandas-qt for Import Dialog - need to map more features still but its looking good so far. Minor changes to make compatible to python 3+.<commit_after>
import os
from PySide import QtGui, QtCore
from core.views.project.main_ui import Ui_ProjectWindow
from core.utility.collection import SettingsINI
from core.models.filetree import FileTreeModel
from core.views.settings import SettingsDialog
from pandasqt.views.CSVDialogs import CSVImportDialog


class ProjectMainWindow(QtGui.QMainWindow, Ui_ProjectWindow):
    def __init__(self, dirname: str, settings_ini: str):
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)

        self.SettingsDialog = SettingsDialog(filename=settings_ini)
        self.setWindowTitle(self.SettingsDialog.rootDirectoryLineEdit.text())
        self.connect_actions()
        self.connect_filetree()
        self.df_models = {}

    def connect_actions(self):
        self.actionPreferences.triggered.connect(self.open_settings_dialog)
        self.actionNew.triggered.connect(self.open_csv)

    def connect_filetree(self):
        rootdir = self.SettingsDialog.rootDirectoryLineEdit.text()
        model = FileTreeModel(root_dir=rootdir)
        self.ProjectsTreeView.setModel(model)
        self.ProjectsTreeView.setRootIndex(model.index(rootdir))

    def connect_settings_dialog(self):
        self.SettingsDialog.cloudProviderComboBox.setVisible(False)
        self.SettingsDialog.cloudProviderLabel.setVisible(False)
        self.SettingsDialog.rootDirectoryLabel.setVisible(False)
        self.SettingsDialog.rootDirectoryLineEdit.setVisible(False)

    def open_csv(self):
        Dialog = CSVImportDialog(self)
        Dialog.load.connect(self.import_file)
        Dialog.exec_()

    @QtCore.Slot('DataFrameModel', str)
    def import_file(self, model, filepath):
        name = os.path.basename(filepath)

        self.df_models[name] = model
        dirname = self.SettingsDialog.rootDirectoryLineEdit.text()
        if os.path.dirname(filepath) != dirname:
            self.maybe_save_copy(model.dataFrame(),
                                 os.path.join(dirname, name),
                                 index=False
                                 )

    def maybe_save_copy(self, df, filepath, max_size=20000, **kwargs):
        if df.index.size <= max_size and not df.empty:
            kwargs['index'] = kwargs.get('index', False)
            df.to_csv(filepath, **kwargs)

    def open_settings_dialog(self):
        self.SettingsDialog.exec_()

{'fraction_non_alphanumeric': 0.08632543926661573, 'fraction_numerical': 0.0015278838808250573, 'mean_word_length': 3.4687144482366326, 'pattern_counts': {'":': 0, '<': 4, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2624299', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1086, 'n_words': 191}