Example #1
0
    def open(self, file_name):
        """
        Loads the content from XML file to Project instance.
        """

        # Create the network
        self.network = Network()

        try:
            project = eval(open(file_name, 'r').read())
        except:
            QtWidgets.QMessageBox.warning(None, "Warning", "Cannot read the project file (" + file_name + ")!", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Default, QtWidgets.QMessageBox.NoButton)
            project = {}

        self.file_name = file_name
        self.name = project['name']
        self.author = project['author']
        self.description = project['description']
        for node_dict in project['nodes']:
            node = self.readNode(node_dict)
            self.network.nodes.append(node)
        for link_dict in project['links']:
            link = self.readLink(link_dict)
            self.network.links.append(link)
        self.network.preparePhases()
Example #2
0
    def open(self, fileName):
        """
    Loads the content from XML file to Project instance.
    """

        # Create the network
        self.network = Network()

        self.fileName = fileName
        file = QtCore.QFile(self.fileName)
        if (file.open(QtCore.QIODevice.ReadOnly)):
            xmlReader = QtCore.QXmlStreamReader()
            xmlReader.setDevice(file)
            while (not xmlReader.isEndDocument()):
                if xmlReader.isStartElement():
                    if xmlReader.name().toString() == 'MetaData':
                        self.name = self.__getStringAttribute(
                            xmlReader.attributes(), 'name')
                        self.author = self.__getStringAttribute(
                            xmlReader.attributes(), 'author')
                        self.description = self.__getStringAttribute(
                            xmlReader.attributes(), 'description')
                    elif xmlReader.name().toString() == 'Net':
                        while xmlReader.readNextStartElement():
                            if xmlReader.name().toString() == 'Node':
                                node = self.__readNode(xmlReader)
                                self.network.nodes.append(node)
                            elif xmlReader.name().toString() == 'Link':
                                link = self.__readLink(xmlReader)
                                self.network.links.append(link)

                xmlReader.readNext()
            if (xmlReader.hasError()):
                QtGui.QMessageBox.critical(
                    self, "Critical",
                    "Ocurred a XML error: " + xmlReader.errorString().data(),
                    QtGui.QMessageBox.Ok | QtGui.QMessageBox.Default,
                    QtGui.QMessageBox.NoButton)
        else:
            QtGui.QMessageBox.critical(
                self, "Critical", "Cannot read the project file!",
                QtGui.QMessageBox.Ok | QtGui.QMessageBox.Default,
                QtGui.QMessageBox.NoButton)

        self.network.preparePhases()
Example #3
0
    def new(self):
        """
    Initializes a new instance of this class.
    """

        # Initialize metadata
        self.fileName = ''
        self.name = "Untitled"
        self.author = ""
        self.description = ""

        # Create the top region
        topRegion = Region("TopRegion")

        # Create the network and add topRegion as its starting node
        self.network = Network()
        self.network.nodes.append(topRegion)
        self.network.preparePhases()
Example #4
0
    def __init__(self):
        """
        Initializes a new instance of this class.
        """

        # Project file
        self.file_name = ''

        # Name of the project.
        self.name = "Untitled"

        # Author of the project.
        self.author = ""

        # Description of the project.
        self.description = ""

        # The network created for the project.
        self.network = Network()
Example #5
0
    def __init__(self):
        """
    Initializes a new instance of this class.
    """

        #region Instance fields

        self.fileName = ''
        """Project file"""

        self.name = "Untitled"
        """Name of the project."""

        self.author = ""
        """Author of the project."""

        self.description = ""
        """Description of the project."""

        self.network = Network()
        """The network created for the project."""