E5XML/UserProjectReader.py

Sat, 05 Jul 2014 11:41:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 11:41:14 +0200
changeset 3669
ac84ac3c0f05
parent 3178
f25fc1364c88
child 4021
195a471c327b
permissions
-rw-r--r--

Continued renaming eric5 for PyQt5 to eric6.

# -*- coding: utf-8 -*-

# Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a class for reading an XML user project properties file.
"""

from __future__ import unicode_literals

from .Config import userProjectFileFormatVersion
from .XMLStreamReaderBase import XMLStreamReaderBase

import Preferences


class UserProjectReader(XMLStreamReaderBase):
    """
    Class for reading an XML user project properties file.
    """
    supportedVersions = ["4.0"]
    
    def __init__(self, device, project):
        """
        Constructor
        
        @param device reference to the I/O device to read from (QIODevice)
        @param project Reference to the project object to store the
                information into.
        """
        XMLStreamReaderBase.__init__(self, device)
    
        self.project = project
        
        self.version = ""
    
    def readXML(self):
        """
        Public method to read and parse the XML document.
        """
        while not self.atEnd():
            self.readNext()
            if self.isStartElement():
                if self.name() == "UserProject":
                    self.version = self.attribute(
                        "version", userProjectFileFormatVersion)
                    if self.version not in self.supportedVersions:
                        self.raiseUnsupportedFormatVersion(self.version)
                elif self.name() == "VcsType":
                    self.project.pudata["VCSOVERRIDE"] = [
                        self.readElementText()]
                elif self.name() == "VcsStatusMonitorInterval":
                    interval = int(self.attribute(
                        "value",
                        Preferences.getVCS("StatusMonitorInterval")))
                    self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [
                        interval]
                else:
                    self.raiseUnexpectedStartTag(self.name())
        
        self.showErrorMessage()

eric ide

mercurial