E5XML/SessionWriter.py

Fri, 10 Sep 2010 08:54:33 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 10 Sep 2010 08:54:33 +0200
changeset 580
45c38566b001
parent 411
99409cddaaa9
child 599
ee87fe94bf96
permissions
-rw-r--r--

Implemented the plug-in repository reader.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
13
1af94a91f439 Changed copyright for 2010.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 12
diff changeset
3 # Copyright (c) 2004 - 2010 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the writer class for writing an XML project session file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import time
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
12 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
14 from .XMLWriterBase import XMLWriterBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
15 from .Config import sessionFileFormatVersion
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class SessionWriter(XMLWriterBase):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing the writer class for writing an XML project session file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 def __init__(self, file, projectName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param file open file (like) object for writing
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param projectName name of the project (string) or None for the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 global session
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 XMLWriterBase.__init__(self, file)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.name = projectName
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
34 self.project = e5App().getObject("Project")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
35 self.multiProject = e5App().getObject("MultiProject")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
36 self.vm = e5App().getObject("ViewManager")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
37 self.dbg = e5App().getObject("DebugUI")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
38 self.dbs = e5App().getObject("DebugServer")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 def writeXML(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Public method to write the XML to the file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 isGlobal = self.name is None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 XMLWriterBase.writeXML(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
48 self._write('<!DOCTYPE Session SYSTEM "Session-{0}.dtd">'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
49 sessionFileFormatVersion))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 # add some generation comments
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 if not isGlobal:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
53 self._write("<!-- eric5 session file for project {0} -->".format(self.name))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self._write("<!-- This file was generated automatically, do not edit. -->")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 if Preferences.getProject("XMLTimestamp") or isGlobal:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
56 self._write("<!-- Saved: {0} -->".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 # add the main tag
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
59 self._write('<Session version="{0}">'.format(sessionFileFormatVersion))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 # step 0: save open multi project and project for the global session
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 if isGlobal:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 if self.multiProject.isOpen():
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
64 self._write(' <MultiProject>{0}</MultiProject>'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
65 self.multiProject.getMultiProjectFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 if self.project.isOpen():
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
67 self._write(' <Project>{0}</Project>'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
68 self.project.getProjectFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 # step 1: save all open (project) filenames and the active window
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 allOpenFiles = self.vm.getOpenFilenames()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self._write(" <Filenames>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 for of in allOpenFiles:
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
74 if isGlobal or of.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 ed = self.vm.getOpenEditor(of)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if ed is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 line, index = ed.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 folds = ','.join([str(i + 1) for i in ed.getFolds()])
228
1cce8982e636 Added code to save the editor zoom factor in the session file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
79 zoom = ed.getZoom()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 line, index = 0, 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 folds = ''
229
fa7024a3cd58 Fixed a bug introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 228
diff changeset
83 zoom = -9999
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
84 self._write(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
85 ' <Filename cline="{0:d}" cindex="{1:d}" folds="{2}" zoom="{3:d}">'
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
86 '{4}</Filename>'.format(line, index, folds, zoom, of))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self._write(" </Filenames>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 aw = self.vm.getActiveName()
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
90 if aw and aw.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 ed = self.vm.getOpenEditor(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if ed is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 line, index = ed.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 line, index = 0, 0
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
96 self._write(' <ActiveWindow cline="{0:d}" cindex="{1:d}">{2}</ActiveWindow>'\
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
97 .format(line, index, aw))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 # step 2a: save all breakpoints
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 allBreaks = Preferences.getProject("SessionAllBreakpoints")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 projectFiles = self.project.getSources(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 bpModel = self.dbs.getBreakPointModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self._write(" <Breakpoints>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 for row in range(bpModel.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 index = bpModel.index(row, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 fname, lineno, cond, temp, enabled, count = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 bpModel.getBreakPointByIndex(index)[:6]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 if isGlobal or allBreaks or fname in projectFiles:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self._write(" <Breakpoint>")
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
110 self._write(" <BpFilename>{0}</BpFilename>".format(fname))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
111 self._write(' <Linenumber value="{0:d}" />'.format(lineno))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
112 self._write(" <Condition>{0}</Condition>".format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
113 self.escape(str(cond))))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
114 self._write(' <Temporary value="{0}" />'.format(temp))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
115 self._write(' <Enabled value="{0}" />'.format(enabled))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
116 self._write(' <Count value="{0:d}" />'.format(count))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self._write(" </Breakpoint>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self._write(" </Breakpoints>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 # step 2b: save all watch expressions
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self._write(" <Watchexpressions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 wpModel = self.dbs.getWatchPointModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 for row in range(wpModel.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 index = wpModel.index(row, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 cond, temp, enabled, count, special = wpModel.getWatchPointByIndex(index)[:5]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self._write(' <Watchexpression>')
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
127 self._write(" <Condition>{0}</Condition>".format(self.escape(str(cond))))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
128 self._write(' <Temporary value="{0}" />'.format(temp))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
129 self._write(' <Enabled value="{0}" />'.format(enabled))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
130 self._write(' <Count value="{0:d}" />'.format(count))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
131 self._write(' <Special>{0}</Special>'.format(special))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self._write(' </Watchexpression>')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self._write(' </Watchexpressions>')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 # step 3: save the debug info
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self._write(" <DebugInfo>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 if isGlobal:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if len(self.dbg.argvHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 dbgCmdline = str(self.dbg.argvHistory[0])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 dbgCmdline = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if len(self.dbg.wdHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 dbgWd = self.dbg.wdHistory[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 dbgWd = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 if len(self.dbg.envHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 dbgEnv = self.dbg.envHistory[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 dbgEnv = ""
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
150 self._write(" <CommandLine>{0}</CommandLine>"\
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
151 .format(self.escape(dbgCmdline)))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
152 self._write(" <WorkingDirectory>{0}</WorkingDirectory>".format(dbgWd))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
153 self._write(" <Environment>{0}</Environment>".format(dbgEnv))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
154 self._write(' <ReportExceptions value="{0}" />'\
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
155 .format(self.dbg.exceptions))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self._write(" <Exceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 for exc in self.dbg.excList:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
158 self._write(" <Exception>{0}</Exception>".format(exc))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self._write(" </Exceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self._write(" <IgnoredExceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 for iexc in self.dbg.excIgnoreList:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
162 self._write(" <IgnoredException>{0}</IgnoredException>".format(iexc))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self._write(" </IgnoredExceptions>")
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
164 self._write(' <AutoClearShell value="{0}" />'\
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
165 .format(self.dbg.autoClearShell))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
166 self._write(' <TracePython value="{0}" />'.format(self.dbg.tracePython))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
167 self._write(' <AutoContinue value="{0}" />'.format(self.dbg.autoContinue))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 self._write(" <CovexcPattern></CovexcPattern>") # kept for compatibility
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 else:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
170 self._write(" <CommandLine>{0}</CommandLine>".format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
171 self.escape(str(self.project.dbgCmdline))))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
172 self._write(" <WorkingDirectory>{0}</WorkingDirectory>".format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
173 self.project.dbgWd))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
174 self._write(" <Environment>{0}</Environment>".format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
175 self.project.dbgEnv))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
176 self._write(' <ReportExceptions value="{0}" />'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
177 self.project.dbgReportExceptions))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self._write(" <Exceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 for exc in self.project.dbgExcList:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
180 self._write(" <Exception>{0}</Exception>".format(exc))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 self._write(" </Exceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self._write(" <IgnoredExceptions>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 for iexc in self.project.dbgExcIgnoreList:
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
184 self._write(" <IgnoredException>{0}</IgnoredException>".format(iexc))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self._write(" </IgnoredExceptions>")
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
186 self._write(' <AutoClearShell value="{0}" />'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
187 self.project.dbgAutoClearShell))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
188 self._write(' <TracePython value="{0}" />'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
189 self.project.dbgTracePython))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
190 self._write(' <AutoContinue value="{0}" />'.format(
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
191 self.project.dbgAutoContinue))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self._write(" <CovexcPattern></CovexcPattern>") # kept for compatibility
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self._write(" </DebugInfo>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 # step 4: save bookmarks of all open (project) files
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self._write(" <Bookmarks>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 for of in allOpenFiles:
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
198 if isGlobal or of.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 editor = self.vm.getOpenEditor(of)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 for bookmark in editor.getBookmarks():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self._write(" <Bookmark>")
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
202 self._write(" <BmFilename>{0}</BmFilename>".format(of))
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
203 self._write(' <Linenumber value="{0:d}" />'.format(bookmark))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self._write(" </Bookmark>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self._write(" </Bookmarks>")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
207 self._write("</Session>", newline = False)

eric ide

mercurial