eric7/E5XML/DebuggerPropertiesReader.py

branch
eric7
changeset 8312
800c432b34c8
parent 7923
91e843545d9a
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a class for reading an XML project debugger properties
8 file.
9 """
10
11 from .Config import debuggerPropertiesFileFormatVersion
12 from .XMLStreamReaderBase import XMLStreamReaderBase
13
14
15 class DebuggerPropertiesReader(XMLStreamReaderBase):
16 """
17 Class for reading an XML project debugger properties file.
18 """
19 supportedVersions = ["3.9", "6.0"]
20
21 def __init__(self, device, project):
22 """
23 Constructor
24
25 @param device reference to the I/O device to read from (QIODevice)
26 @param project Reference to the project object to store the
27 information into.
28 """
29 XMLStreamReaderBase.__init__(self, device)
30
31 self.project = project
32
33 self.version = ""
34
35 def readXML(self, quiet=False):
36 """
37 Public method to read and parse the XML document.
38
39 @param quiet flag indicating quiet operations.
40 If this flag is true, no errors are reported.
41 """
42 while not self.atEnd():
43 self.readNext()
44 if self.isStartElement():
45 if self.name() == "DebuggerProperties":
46 self.version = self.attribute(
47 "version", debuggerPropertiesFileFormatVersion)
48 if self.version not in self.supportedVersions:
49 self.raiseUnsupportedFormatVersion(self.version)
50 elif self.name() == "VirtualEnv":
51 self.project.debugProperties["VIRTUALENV"] = (
52 self.readElementText()
53 )
54 elif self.name() == "Interpreter":
55 # just read this obsolete entry and ignore it
56 self.readElementText()
57 elif self.name() == "DebugClient":
58 self.project.debugProperties["DEBUGCLIENT"] = (
59 self.readElementText()
60 )
61 elif self.name() == "Environment":
62 self.project.debugProperties["ENVIRONMENTOVERRIDE"] = (
63 int(self.attribute("override", "0"))
64 )
65 self.project.debugProperties["ENVIRONMENTSTRING"] = (
66 self.readElementText()
67 )
68 elif self.name() == "RemoteDebugger":
69 self.__readRemoteDebugger()
70 elif self.name() == "PathTranslation":
71 self.__readPathTranslation()
72 elif self.name() == "ConsoleDebugger":
73 self.project.debugProperties["CONSOLEDEBUGGER"] = (
74 int(self.attribute("on", "0"))
75 )
76 self.project.debugProperties["CONSOLECOMMAND"] = (
77 self.readElementText()
78 )
79 elif self.name() == "Redirect":
80 self.project.debugProperties["REDIRECT"] = (
81 int(self.attribute("on", "1"))
82 )
83 elif self.name() == "Noencoding":
84 self.project.debugProperties["NOENCODING"] = (
85 int(self.attribute("on", "0"))
86 )
87 else:
88 self.raiseUnexpectedStartTag(self.name())
89
90 if not quiet:
91 self.showErrorMessage()
92
93 def __readRemoteDebugger(self):
94 """
95 Private method to read the remote debugger info.
96 """
97 self.project.debugProperties["REMOTEDEBUGGER"] = int(self.attribute(
98 "on", "0"))
99
100 while not self.atEnd():
101 self.readNext()
102 if self.isEndElement() and self.name() == "RemoteDebugger":
103 break
104
105 if self.isStartElement():
106 if self.name() == "RemoteHost":
107 self.project.debugProperties["REMOTEHOST"] = (
108 self.readElementText()
109 )
110 elif self.name() == "RemoteCommand":
111 self.project.debugProperties["REMOTECOMMAND"] = (
112 self.readElementText()
113 )
114 else:
115 self.raiseUnexpectedStartTag(self.name())
116
117 def __readPathTranslation(self):
118 """
119 Private method to read the path translation info.
120 """
121 self.project.debugProperties["PATHTRANSLATION"] = int(self.attribute(
122 "on", "0"))
123
124 while not self.atEnd():
125 self.readNext()
126 if self.isEndElement() and self.name() == "PathTranslation":
127 break
128
129 if self.isStartElement():
130 if self.name() == "RemotePath":
131 self.project.debugProperties["REMOTEPATH"] = (
132 self.readElementText()
133 )
134 elif self.name() == "LocalPath":
135 self.project.debugProperties["LOCALPATH"] = (
136 self.readElementText()
137 )
138 else:
139 self.raiseUnexpectedStartTag(self.name())

eric ide

mercurial