|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 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.buffer = self.utf8_to_code(self.buffer) |
|
56 self.project.pudata["VCSOVERRIDE"] = [self.buffer] |
|
57 |
|
58 def startVcsStatusMonitorInterval(self, attrs): |
|
59 """ |
|
60 Handler method for the "VcsStatusMonitorInterval" start tag. |
|
61 |
|
62 @param attrs list of tag attributes |
|
63 """ |
|
64 interval = int(attrs.get("value", Preferences.getVCS("StatusMonitorInterval"))) |
|
65 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [interval] |
|
66 |
|
67 def startUserProject(self, attrs): |
|
68 """ |
|
69 Handler method for the "UserProject" start tag. |
|
70 |
|
71 @param attrs list of tag attributes |
|
72 """ |
|
73 self.version = attrs.get('version', userProjectFileFormatVersion) |
|
74 |
|
75 def getVersion(self): |
|
76 """ |
|
77 Public method to retrieve the version of the user project file. |
|
78 |
|
79 @return String containing the version number. |
|
80 """ |
|
81 return self.version |