<commit_before>from PyQt5.QtWidgets import QMainWindow, QApplication
from gui.PyreeMainWindow import Ui_PyreeMainWindow

import sys



class PyreeMainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(PyreeMainWindow, self).__init__(*args, **kwargs)

        # Import UI from QT designer
        self.ui = Ui_PyreeMainWindow()
        self.ui.setupUi(self)



if __name__ == "__main__":
    app = QApplication(sys.argv)

    mainwin = PyreeMainWindow()
    mainwin.show()

    ret = app.exec()

    sys.exit(ret)
<commit_msg>Add ability to create new sheets<commit_after>from PyQt5.QtWidgets import QMainWindow, QApplication, QListWidgetItem
from PyQt5.QtCore import Qt, QMimeData, QMimeType
from gui.PyreeMainWindow import Ui_PyreeMainWindow

from effigy.QNodeScene import QNodeScene
from effigy.QNodeSceneNode import QNodeSceneNode

import sys, os
import uuid

class Sheet():
    """Sheet manager

    Represents one sheet. Manages the QNodeScene and (de-)serialization."""
    def __init__(self, listItem:QListWidgetItem, data=None):
        self.scene = QNodeScene()
        self.listItem = listItem

    def saveToFile(self, path):
        data = {}
        nodes = [x for x in self.scene.items() if issubclass(type(x), QNodeSceneNode)]  # Get all nodes in scene

        data["nodes"] = {}
        for node in nodes:
            data["nodes"][node.id] = node.serializeinternal()

class PyreeProject():
    """Pyree Project

    This class manages a project in Pyree. It encompasses management of all sheets as well as storing project settings.
    It also contains saving and loading features."""
    def __init__(self, listWidget, filePath:str=None):
        self.filePath = filePath
        self.listWidget = listWidget

        self.sheets = {}    # List of all sheets in the project

        if filePath is not None:
            self.loadFromFile(filePath)

    def loadFromFile(self, path):
        """Load project from file"""
        data = {}

        self.projectName = data["projectName"]

    def saveToFile(self, path):
        """Save current project to file"""
        data = {}
        data["sheets"] = {}
        for i in range(self.listWidget.count()):
            listItem = self.ui.listWidget.item(i)
            # TODO: Write sheets to file

    def newSheet(self, listItem, data=None):
        """Create a new sheet and store it in sheets"""
        self.sheets[listItem.data(Qt.UserRole)] = Sheet(listItem, data)

class PyreeMainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(PyreeMainWindow, self).__init__(*args, **kwargs)

        # Import UI from QT designer
        self.ui = Ui_PyreeMainWindow()
        self.ui.setupUi(self)

        self.currentProject = PyreeProject(self.ui.sheetListWidget)

        # Also triggered by pressing enter on sheetLineEdit
        self.ui.addSheetPushButton.clicked.connect(self.addSheetPushButtonClicked)
        self.ui.sheetListWidget.itemChanged.connect(self.SheetListWidgetItemChanged)

    def addSheetPushButtonClicked(self, checked):
        if self.ui.addSheetLineEdit.text():     # If the text field isn't empty
            newTreeItem = QListWidgetItem(self.ui.addSheetLineEdit.text(), self.ui.sheetListWidget)
            newTreeItem.setData(Qt.UserRole, uuid.uuid4())  # Add some uniquely identifying data to make it hashable
            self.currentProject.newSheet(newTreeItem)

    def sheetListWidgetItemChanges(self, item):
        pass    # TODO: Decide if this is needed

if __name__ == "__main__":
    app = QApplication(sys.argv)

    mainwin = PyreeMainWindow()
    mainwin.show()

    ret = app.exec()

    sys.exit(ret)

{'fraction_non_alphanumeric': 0.09847244953627933, 'fraction_numerical': 0.0010911074740861974, 'mean_word_length': 3.0564159292035398, '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': '6727525', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1079, 'n_words': 292}