E4XML/UserProjectHandler.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/E4XML/UserProjectHandler.py	Mon Dec 28 16:03:33 2009 +0000
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing the handler class for reading an XML user project properties file.
+"""
+
+import os
+
+from Config import userProjectFileFormatVersion
+from XMLHandlerBase import XMLHandlerBase
+
+import Preferences
+
+class UserProjectHandler(XMLHandlerBase):
+    """
+    Class implementing a sax handler to read an XML user project properties file.
+    """
+    def __init__(self, project):
+        """
+        Constructor
+        
+        @param project Reference to the project object to store the
+                information into.
+        """
+        XMLHandlerBase.__init__(self)
+        
+        self.startDocumentSpecific = self.startDocumentProject
+        
+        self.elements.update({
+            'UserProject' : (self.startUserProject, self.defaultEndElement),
+            'VcsType' : (self.defaultStartElement, self.endVcsType),
+            'VcsStatusMonitorInterval' : (self.startVcsStatusMonitorInterval, 
+                                          self.defaultEndElement),
+        })
+    
+        self.project = project
+        
+    def startDocumentProject(self):
+        """
+        Handler called, when the document parsing is started.
+        """
+        self.version = ''
+        
+    ###################################################
+    ## below follow the individual handler functions
+    ###################################################
+    
+    def endVcsType(self):
+        """
+        Handler method for the "VcsType" end tag.
+        """
+        self.buffer = self.utf8_to_code(self.buffer)
+        self.project.pudata["VCSOVERRIDE"] = [self.buffer]
+        
+    def startVcsStatusMonitorInterval(self, attrs):
+        """
+        Handler method for the "VcsStatusMonitorInterval" start tag.
+        
+        @param attrs list of tag attributes
+        """
+        interval = int(attrs.get("value", Preferences.getVCS("StatusMonitorInterval")))
+        self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [interval]
+        
+    def startUserProject(self, attrs):
+        """
+        Handler method for the "UserProject" start tag.
+        
+        @param attrs list of tag attributes
+        """
+        self.version = attrs.get('version', userProjectFileFormatVersion)
+        
+    def getVersion(self):
+        """
+        Public method to retrieve the version of the user project file.
+        
+        @return String containing the version number.
+        """
+        return self.version

eric ide

mercurial