E5XML/UserProjectHandler.py

changeset 50
a36eecf45b2e
parent 45
9a18f4dbb493
child 96
9624a110667d
equal deleted inserted replaced
49:f991944e859c 50:a36eecf45b2e
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2010 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the handler class for reading an XML user project properties file.
8 """
9
10 import os
11
12 from .Config import userProjectFileFormatVersion
13 from .XMLHandlerBase import XMLHandlerBase
14
15 import Preferences
16
17 class UserProjectHandler(XMLHandlerBase):
18 """
19 Class implementing a sax handler to read an XML user project properties file.
20 """
21 def __init__(self, project):
22 """
23 Constructor
24
25 @param project Reference to the project object to store the
26 information into.
27 """
28 XMLHandlerBase.__init__(self)
29
30 self.startDocumentSpecific = self.startDocumentProject
31
32 self.elements.update({
33 'UserProject' : (self.startUserProject, self.defaultEndElement),
34 'VcsType' : (self.defaultStartElement, self.endVcsType),
35 'VcsStatusMonitorInterval' : (self.startVcsStatusMonitorInterval,
36 self.defaultEndElement),
37 })
38
39 self.project = project
40
41 def startDocumentProject(self):
42 """
43 Handler called, when the document parsing is started.
44 """
45 self.version = ''
46
47 ###################################################
48 ## below follow the individual handler functions
49 ###################################################
50
51 def endVcsType(self):
52 """
53 Handler method for the "VcsType" end tag.
54 """
55 self.project.pudata["VCSOVERRIDE"] = [self.buffer]
56
57 def startVcsStatusMonitorInterval(self, attrs):
58 """
59 Handler method for the "VcsStatusMonitorInterval" start tag.
60
61 @param attrs list of tag attributes
62 """
63 interval = int(attrs.get("value", Preferences.getVCS("StatusMonitorInterval")))
64 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [interval]
65
66 def startUserProject(self, attrs):
67 """
68 Handler method for the "UserProject" start tag.
69
70 @param attrs list of tag attributes
71 """
72 self.version = attrs.get('version', userProjectFileFormatVersion)
73
74 def getVersion(self):
75 """
76 Public method to retrieve the version of the user project file.
77
78 @return String containing the version number.
79 """
80 return self.version

eric ide

mercurial