E5XML/SessionWriter.py

Sat, 05 Jul 2014 11:41:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 11:41:14 +0200
changeset 3669
ac84ac3c0f05
parent 3600
7d17c492ab95
child 3670
f0cb7579c0b4
permissions
-rw-r--r--

Continued renaming eric5 for PyQt5 to eric6.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
3 # Copyright (c) 2004 - 2014 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 """
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
7 Module implementing the writer class for writing an XML session file.
0
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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3058
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import time
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
14 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
16 from .XMLStreamWriterBase import XMLStreamWriterBase
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
17 from .Config import sessionFileFormatVersion
0
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 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
21
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
22 class SessionWriter(XMLStreamWriterBase):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
24 Class implementing the writer class for writing an XML session file.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
26 def __init__(self, device, projectName):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
30 @param device reference to the I/O device to write to (QIODevice)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @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
32 global session
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
34 XMLStreamWriterBase.__init__(self, device)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.name = projectName
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
37 self.project = e5App().getObject("Project")
3600
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
38 self.projectBrowser = e5App().getObject("ProjectBrowser")
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
39 self.multiProject = e5App().getObject("MultiProject")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
40 self.vm = e5App().getObject("ViewManager")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
41 self.dbg = e5App().getObject("DebugUI")
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
42 self.dbs = e5App().getObject("DebugServer")
0
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 def writeXML(self):
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 Public method to write the XML to the file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 isGlobal = self.name is None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
50 XMLStreamWriterBase.writeXML(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
52 self.writeDTD('<!DOCTYPE Session SYSTEM "Session-{0}.dtd">'.format(
411
99409cddaaa9 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 229
diff changeset
53 sessionFileFormatVersion))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 # add some generation comments
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 if not isGlobal:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
57 self.writeComment(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
58 " eric5 session file for project {0} ".format(self.name))
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
59 self.writeComment(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
60 " This file was generated automatically, do not edit. ")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 if Preferences.getProject("XMLTimestamp") or isGlobal:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
62 self.writeComment(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
63 " 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
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 # add the main tag
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
66 self.writeStartElement("Session")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
67 self.writeAttribute("version", sessionFileFormatVersion)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 # 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
70 if isGlobal:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 if self.multiProject.isOpen():
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
72 self.writeTextElement(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
73 "MultiProject", self.multiProject.getMultiProjectFile())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 if self.project.isOpen():
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
75 self.writeTextElement("Project", self.project.getProjectFile())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 # 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
78 allOpenFiles = self.vm.getOpenFilenames()
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
79 self.writeStartElement("Filenames")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 for of in allOpenFiles:
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
81 if isGlobal or of.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 ed = self.vm.getOpenEditor(of)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 if ed is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 line, index = ed.getCursorPosition()
938
f421f2138c0f Adjusted code to use the QScintilla contractedFolds() and setContractedFolds() methods (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
85 folds = ','.join(
f421f2138c0f Adjusted code to use the QScintilla contractedFolds() and setContractedFolds() methods (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
86 [str(i + 1) for i in ed.contractedFolds()])
228
1cce8982e636 Added code to save the editor zoom factor in the session file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
87 zoom = ed.getZoom()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 line, index = 0, 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 folds = ''
229
fa7024a3cd58 Fixed a bug introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 228
diff changeset
91 zoom = -9999
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
92 self.writeStartElement("Filename")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
93 self.writeAttribute("cline", str(line))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
94 self.writeAttribute("cindex", str(index))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
95 self.writeAttribute("folds", folds)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
96 self.writeAttribute("zoom", str(zoom))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
97 self.writeCharacters(of)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
98 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
99 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 aw = self.vm.getActiveName()
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
102 if aw and aw.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 ed = self.vm.getOpenEditor(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 if ed is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 line, index = ed.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 line, index = 0, 0
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
108 self.writeStartElement("ActiveWindow")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
109 self.writeAttribute("cline", str(line))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
110 self.writeAttribute("cindex", str(index))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
111 self.writeCharacters(aw)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
112 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 # step 2a: save all breakpoints
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 allBreaks = Preferences.getProject("SessionAllBreakpoints")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 projectFiles = self.project.getSources(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 bpModel = self.dbs.getBreakPointModel()
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
118 self.writeStartElement("Breakpoints")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 for row in range(bpModel.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 index = bpModel.index(row, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 fname, lineno, cond, temp, enabled, count = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 bpModel.getBreakPointByIndex(index)[:6]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 if isGlobal or allBreaks or fname in projectFiles:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
124 self.writeStartElement("Breakpoint")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
125 self.writeTextElement("BpFilename", fname)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
126 self.writeEmptyElement("Linenumber")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
127 self.writeAttribute("value", str(lineno))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
128 self.writeTextElement("Condition", str(cond))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
129 self.writeEmptyElement("Temporary")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
130 self.writeAttribute("value", str(temp))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
131 self.writeEmptyElement("Enabled")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
132 self.writeAttribute("value", str(enabled))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
133 self.writeEmptyElement("Count")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
134 self.writeAttribute("value", str(count))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
135 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
136 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 # step 2b: save all watch expressions
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
139 self.writeStartElement("Watchexpressions")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 wpModel = self.dbs.getWatchPointModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 for row in range(wpModel.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 index = wpModel.index(row, 0)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
143 cond, temp, enabled, count, special = \
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
144 wpModel.getWatchPointByIndex(index)[:5]
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
145 self.writeStartElement("Watchexpression")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
146 self.writeTextElement("Condition", str(cond))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
147 self.writeEmptyElement("Temporary")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
148 self.writeAttribute("value", str(temp))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
149 self.writeEmptyElement("Enabled")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
150 self.writeAttribute("value", str(enabled))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
151 self.writeEmptyElement("Count")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
152 self.writeAttribute("value", str(count))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
153 self.writeTextElement("Special", special)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
154 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
155 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 # step 3: save the debug info
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
158 self.writeStartElement("DebugInfo")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 if isGlobal:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if len(self.dbg.argvHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 dbgCmdline = str(self.dbg.argvHistory[0])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 dbgCmdline = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 if len(self.dbg.wdHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 dbgWd = self.dbg.wdHistory[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 dbgWd = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if len(self.dbg.envHistory):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 dbgEnv = self.dbg.envHistory[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 dbgEnv = ""
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
172 self.writeTextElement("CommandLine", dbgCmdline)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
173 self.writeTextElement("WorkingDirectory", dbgWd)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
174 self.writeTextElement("Environment", dbgEnv)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
175 self.writeEmptyElement("ReportExceptions")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
176 self.writeAttribute("value", str(self.dbg.exceptions))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
177 self.writeStartElement("Exceptions")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 for exc in self.dbg.excList:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
179 self.writeTextElement("Exception", exc)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
180 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
181 self.writeStartElement("IgnoredExceptions")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 for iexc in self.dbg.excIgnoreList:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
183 self.writeTextElement("IgnoredException", iexc)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
184 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
185 self.writeEmptyElement("AutoClearShell")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
186 self.writeAttribute("value", str(self.dbg.autoClearShell))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
187 self.writeEmptyElement("TracePython")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
188 self.writeAttribute("value", str(self.dbg.tracePython))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
189 self.writeEmptyElement("AutoContinue")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
190 self.writeAttribute("value", str(self.dbg.autoContinue))
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
191 self.writeEmptyElement("CovexcPattern") # kept for compatibility
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 else:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
193 self.writeTextElement("CommandLine", self.project.dbgCmdline)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
194 self.writeTextElement("WorkingDirectory", self.project.dbgWd)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
195 self.writeTextElement("Environment", self.project.dbgEnv)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
196 self.writeEmptyElement("ReportExceptions")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
197 self.writeAttribute("value", str(self.project.dbgReportExceptions))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
198 self.writeStartElement("Exceptions")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 for exc in self.project.dbgExcList:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
200 self.writeTextElement("Exception", exc)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
201 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
202 self.writeStartElement("IgnoredExceptions")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 for iexc in self.project.dbgExcIgnoreList:
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
204 self.writeTextElement("IgnoredException", iexc)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
205 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
206 self.writeEmptyElement("AutoClearShell")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
207 self.writeAttribute("value", str(self.project.dbgAutoClearShell))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
208 self.writeEmptyElement("TracePython")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
209 self.writeAttribute("value", str(self.project.dbgTracePython))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
210 self.writeEmptyElement("AutoContinue")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
211 self.writeAttribute("value", str(self.project.dbgAutoContinue))
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
212 self.writeEmptyElement("CovexcPattern") # kept for compatibility
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
213 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 # step 4: save bookmarks of all open (project) files
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
216 self.writeStartElement("Bookmarks")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 for of in allOpenFiles:
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
218 if isGlobal or of.startswith(self.project.ppath):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 editor = self.vm.getOpenEditor(of)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 for bookmark in editor.getBookmarks():
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
221 self.writeStartElement("Bookmark")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
222 self.writeTextElement("BmFilename", of)
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
223 self.writeEmptyElement("Linenumber")
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
224 self.writeAttribute("value", str(bookmark))
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
225 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
226 self.writeEndElement()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
3600
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
228 # step 5: save state of the various project browsers
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
229 if not isGlobal:
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
230 self.writeStartElement("ProjectBrowserStates")
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
231 for browserName in self.projectBrowser.getProjectBrowserNames():
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
232 self.writeStartElement("ProjectBrowserState")
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
233 self.writeAttribute("name", browserName)
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
234 # get the names of expanded files and directories
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
235 names = self.projectBrowser\
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
236 .getProjectBrowser(browserName).getExpandedItemNames()
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
237 for name in names:
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
238 self.writeTextElement("ExpandedItemName", name)
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
239 self.writeEndElement()
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
240 self.writeEndElement()
7d17c492ab95 Started implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
241
599
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
242 # add the main end tag
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
243 self.writeEndElement()
ee87fe94bf96 Migrated the session handler to session reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 411
diff changeset
244 self.writeEndDocument()

eric ide

mercurial