Migrated the session handler to session reader.

Sun, 12 Sep 2010 18:37:31 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 12 Sep 2010 18:37:31 +0200
changeset 599
ee87fe94bf96
parent 598
76c36b6ebbdb
child 600
ed2589a25982

Migrated the session handler to session reader.

Documentation/Source/eric5.E5XML.SessionHandler.html file | annotate | diff | comparison | revisions
E5XML/SessionHandler.py file | annotate | diff | comparison | revisions
E5XML/SessionReader.py file | annotate | diff | comparison | revisions
E5XML/SessionWriter.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
eric5.e4p file | annotate | diff | comparison | revisions
--- a/Documentation/Source/eric5.E5XML.SessionHandler.html	Sun Sep 12 18:20:15 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,419 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
-'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
-<html><head>
-<title>eric5.E5XML.SessionHandler</title>
-<style>
-body {
-    background: #EDECE6;
-    margin: 0em 1em 10em 1em;
-    color: black;
-}
-
-h1 { color: white; background: #85774A; }
-h2 { color: white; background: #85774A; }
-h3 { color: white; background: #9D936E; }
-h4 { color: white; background: #9D936E; }
-    
-a { color: #BA6D36; }
-
-</style>
-</head>
-<body><a NAME="top" ID="top"></a>
-<h1>eric5.E5XML.SessionHandler</h1>
-<p>
-Module implementing the handler class for reading an XML project session file.
-</p>
-<h3>Global Attributes</h3>
-<table>
-<tr><td>None</td></tr>
-</table>
-<h3>Classes</h3>
-<table>
-<tr>
-<td><a href="#SessionHandler">SessionHandler</a></td>
-<td>Class implementing a sax handler to read an XML project session file.</td>
-</tr>
-</table>
-<h3>Functions</h3>
-<table>
-<tr><td>None</td></tr>
-</table>
-<hr /><hr />
-<a NAME="SessionHandler" ID="SessionHandler"></a>
-<h2>SessionHandler</h2>
-<p>
-    Class implementing a sax handler to read an XML project session file.
-</p>
-<h3>Derived from</h3>
-XMLHandlerBase
-<h3>Class Attributes</h3>
-<table>
-<tr><td>None</td></tr>
-</table>
-<h3>Methods</h3>
-<table>
-<tr>
-<td><a href="#SessionHandler.__init__">SessionHandler</a></td>
-<td>Constructor</td>
-</tr><tr>
-<td><a href="#SessionHandler.endBFilename">endBFilename</a></td>
-<td>Handler method for the "BFilename" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endBookmark">endBookmark</a></td>
-<td>Handler method for the "Bookmark" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endBreakpoint">endBreakpoint</a></td>
-<td>Handler method for the "Breakpoint" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endCommandLine">endCommandLine</a></td>
-<td>Handler method for the "CommandLine" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endCondition">endCondition</a></td>
-<td>Handler method for the "Condition" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endEnvironment">endEnvironment</a></td>
-<td>Handler method for the "Environment" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endException">endException</a></td>
-<td>Handler method for the "Exception" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endExceptions">endExceptions</a></td>
-<td>Handler method for the "Exceptions" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endFilename">endFilename</a></td>
-<td>Handler method for the "Filename" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endIgnoredException">endIgnoredException</a></td>
-<td>Handler method for the "IgnoredException" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endIgnoredExceptions">endIgnoredExceptions</a></td>
-<td>Handler method for the "IgnoredExceptions" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endMultiProject">endMultiProject</a></td>
-<td>Handler method for the "MultiProject" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endProject">endProject</a></td>
-<td>Handler method for the "Project" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endSpecial">endSpecial</a></td>
-<td>Handler method for the "Special" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endWatchexpression">endWatchexpression</a></td>
-<td>Handler method for the "Watchexpression" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.endWorkingDirectory">endWorkingDirectory</a></td>
-<td>Handler method for the "WorkinDirectory" end tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.getVersion">getVersion</a></td>
-<td>Public method to retrieve the version of the session.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startAutoClearShell">startAutoClearShell</a></td>
-<td>Handler method for the "AutoClearShell" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startAutoContinue">startAutoContinue</a></td>
-<td>Handler method for the "AutoContinue" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startBookmark">startBookmark</a></td>
-<td>Handler method for the "Bookmark" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startBreakpoint">startBreakpoint</a></td>
-<td>Handler method for the "Breakpoint" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startCount">startCount</a></td>
-<td>Handler method for the "Count" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startDocumentSession">startDocumentSession</a></td>
-<td>Handler called, when the document parsing is started.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startEnabled">startEnabled</a></td>
-<td>Handler method for the "Enabled" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startExceptions">startExceptions</a></td>
-<td>Handler method for the "Exceptions" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startFilename">startFilename</a></td>
-<td>Handler method for the "Filename" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startIgnoredExceptions">startIgnoredExceptions</a></td>
-<td>Handler method for the "IgnoredExceptions" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startLinenumber">startLinenumber</a></td>
-<td>Handler method for the "Linenumber" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startReportExceptions">startReportExceptions</a></td>
-<td>Handler method for the "ReportExceptions" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startSession">startSession</a></td>
-<td>Handler method for the "Session" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startTemporary">startTemporary</a></td>
-<td>Handler method for the "Temporary" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startTracePython">startTracePython</a></td>
-<td>Handler method for the "TracePython" start tag.</td>
-</tr><tr>
-<td><a href="#SessionHandler.startWatchexpression">startWatchexpression</a></td>
-<td>Handler method for the "Watchexpression" start tag.</td>
-</tr>
-</table>
-<a NAME="SessionHandler.__init__" ID="SessionHandler.__init__"></a>
-<h4>SessionHandler (Constructor)</h4>
-<b>SessionHandler</b>(<i>project</i>)
-<p>
-        Constructor
-</p><dl>
-<dt><i>project</i></dt>
-<dd>
-Reference to the project object to store the
-                information into.
-</dd>
-</dl><a NAME="SessionHandler.endBFilename" ID="SessionHandler.endBFilename"></a>
-<h4>SessionHandler.endBFilename</h4>
-<b>endBFilename</b>(<i></i>)
-<p>
-        Handler method for the "BFilename" end tag.
-</p><a NAME="SessionHandler.endBookmark" ID="SessionHandler.endBookmark"></a>
-<h4>SessionHandler.endBookmark</h4>
-<b>endBookmark</b>(<i></i>)
-<p>
-        Handler method for the "Bookmark" end tag.
-</p><a NAME="SessionHandler.endBreakpoint" ID="SessionHandler.endBreakpoint"></a>
-<h4>SessionHandler.endBreakpoint</h4>
-<b>endBreakpoint</b>(<i></i>)
-<p>
-        Handler method for the "Breakpoint" end tag.
-</p><a NAME="SessionHandler.endCommandLine" ID="SessionHandler.endCommandLine"></a>
-<h4>SessionHandler.endCommandLine</h4>
-<b>endCommandLine</b>(<i></i>)
-<p>
-        Handler method for the "CommandLine" end tag.
-</p><a NAME="SessionHandler.endCondition" ID="SessionHandler.endCondition"></a>
-<h4>SessionHandler.endCondition</h4>
-<b>endCondition</b>(<i></i>)
-<p>
-        Handler method for the "Condition" end tag.
-</p><a NAME="SessionHandler.endEnvironment" ID="SessionHandler.endEnvironment"></a>
-<h4>SessionHandler.endEnvironment</h4>
-<b>endEnvironment</b>(<i></i>)
-<p>
-        Handler method for the "Environment" end tag.
-</p><a NAME="SessionHandler.endException" ID="SessionHandler.endException"></a>
-<h4>SessionHandler.endException</h4>
-<b>endException</b>(<i></i>)
-<p>
-        Handler method for the "Exception" end tag.
-</p><a NAME="SessionHandler.endExceptions" ID="SessionHandler.endExceptions"></a>
-<h4>SessionHandler.endExceptions</h4>
-<b>endExceptions</b>(<i></i>)
-<p>
-        Handler method for the "Exceptions" end tag.
-</p><a NAME="SessionHandler.endFilename" ID="SessionHandler.endFilename"></a>
-<h4>SessionHandler.endFilename</h4>
-<b>endFilename</b>(<i></i>)
-<p>
-        Handler method for the "Filename" end tag.
-</p><a NAME="SessionHandler.endIgnoredException" ID="SessionHandler.endIgnoredException"></a>
-<h4>SessionHandler.endIgnoredException</h4>
-<b>endIgnoredException</b>(<i></i>)
-<p>
-        Handler method for the "IgnoredException" end tag.
-</p><a NAME="SessionHandler.endIgnoredExceptions" ID="SessionHandler.endIgnoredExceptions"></a>
-<h4>SessionHandler.endIgnoredExceptions</h4>
-<b>endIgnoredExceptions</b>(<i></i>)
-<p>
-        Handler method for the "IgnoredExceptions" end tag.
-</p><a NAME="SessionHandler.endMultiProject" ID="SessionHandler.endMultiProject"></a>
-<h4>SessionHandler.endMultiProject</h4>
-<b>endMultiProject</b>(<i></i>)
-<p>
-        Handler method for the "MultiProject" end tag.
-</p><a NAME="SessionHandler.endProject" ID="SessionHandler.endProject"></a>
-<h4>SessionHandler.endProject</h4>
-<b>endProject</b>(<i></i>)
-<p>
-        Handler method for the "Project" end tag.
-</p><a NAME="SessionHandler.endSpecial" ID="SessionHandler.endSpecial"></a>
-<h4>SessionHandler.endSpecial</h4>
-<b>endSpecial</b>(<i></i>)
-<p>
-        Handler method for the "Special" end tag.
-</p><a NAME="SessionHandler.endWatchexpression" ID="SessionHandler.endWatchexpression"></a>
-<h4>SessionHandler.endWatchexpression</h4>
-<b>endWatchexpression</b>(<i></i>)
-<p>
-        Handler method for the "Watchexpression" end tag.
-</p><a NAME="SessionHandler.endWorkingDirectory" ID="SessionHandler.endWorkingDirectory"></a>
-<h4>SessionHandler.endWorkingDirectory</h4>
-<b>endWorkingDirectory</b>(<i></i>)
-<p>
-        Handler method for the "WorkinDirectory" end tag.
-</p><a NAME="SessionHandler.getVersion" ID="SessionHandler.getVersion"></a>
-<h4>SessionHandler.getVersion</h4>
-<b>getVersion</b>(<i></i>)
-<p>
-        Public method to retrieve the version of the session.
-</p><dl>
-<dt>Returns:</dt>
-<dd>
-String containing the version number.
-</dd>
-</dl><a NAME="SessionHandler.startAutoClearShell" ID="SessionHandler.startAutoClearShell"></a>
-<h4>SessionHandler.startAutoClearShell</h4>
-<b>startAutoClearShell</b>(<i>attrs</i>)
-<p>
-        Handler method for the "AutoClearShell" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startAutoContinue" ID="SessionHandler.startAutoContinue"></a>
-<h4>SessionHandler.startAutoContinue</h4>
-<b>startAutoContinue</b>(<i>attrs</i>)
-<p>
-        Handler method for the "AutoContinue" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startBookmark" ID="SessionHandler.startBookmark"></a>
-<h4>SessionHandler.startBookmark</h4>
-<b>startBookmark</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Bookmark" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startBreakpoint" ID="SessionHandler.startBreakpoint"></a>
-<h4>SessionHandler.startBreakpoint</h4>
-<b>startBreakpoint</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Breakpoint" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startCount" ID="SessionHandler.startCount"></a>
-<h4>SessionHandler.startCount</h4>
-<b>startCount</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Count" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startDocumentSession" ID="SessionHandler.startDocumentSession"></a>
-<h4>SessionHandler.startDocumentSession</h4>
-<b>startDocumentSession</b>(<i></i>)
-<p>
-        Handler called, when the document parsing is started.
-</p><a NAME="SessionHandler.startEnabled" ID="SessionHandler.startEnabled"></a>
-<h4>SessionHandler.startEnabled</h4>
-<b>startEnabled</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Enabled" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startExceptions" ID="SessionHandler.startExceptions"></a>
-<h4>SessionHandler.startExceptions</h4>
-<b>startExceptions</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Exceptions" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startFilename" ID="SessionHandler.startFilename"></a>
-<h4>SessionHandler.startFilename</h4>
-<b>startFilename</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Filename" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startIgnoredExceptions" ID="SessionHandler.startIgnoredExceptions"></a>
-<h4>SessionHandler.startIgnoredExceptions</h4>
-<b>startIgnoredExceptions</b>(<i>attrs</i>)
-<p>
-        Handler method for the "IgnoredExceptions" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startLinenumber" ID="SessionHandler.startLinenumber"></a>
-<h4>SessionHandler.startLinenumber</h4>
-<b>startLinenumber</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Linenumber" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startReportExceptions" ID="SessionHandler.startReportExceptions"></a>
-<h4>SessionHandler.startReportExceptions</h4>
-<b>startReportExceptions</b>(<i>attrs</i>)
-<p>
-        Handler method for the "ReportExceptions" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startSession" ID="SessionHandler.startSession"></a>
-<h4>SessionHandler.startSession</h4>
-<b>startSession</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Session" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startTemporary" ID="SessionHandler.startTemporary"></a>
-<h4>SessionHandler.startTemporary</h4>
-<b>startTemporary</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Temporary" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startTracePython" ID="SessionHandler.startTracePython"></a>
-<h4>SessionHandler.startTracePython</h4>
-<b>startTracePython</b>(<i>attrs</i>)
-<p>
-        Handler method for the "TracePython" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl><a NAME="SessionHandler.startWatchexpression" ID="SessionHandler.startWatchexpression"></a>
-<h4>SessionHandler.startWatchexpression</h4>
-<b>startWatchexpression</b>(<i>attrs</i>)
-<p>
-        Handler method for the "Watchexpression" start tag.
-</p><dl>
-<dt><i>attrs</i></dt>
-<dd>
-list of tag attributes
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-</body></html>
\ No newline at end of file
--- a/E5XML/SessionHandler.py	Sun Sep 12 18:20:15 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,406 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2003 - 2010 Detlev Offenbach <detlev@die-offenbachs.de>
-#
-
-"""
-Module implementing the handler class for reading an XML project session file.
-"""
-
-from E5Gui.E5Application import e5App
-
-from .Config import sessionFileFormatVersion
-from .XMLHandlerBase import XMLHandlerBase
-
-class SessionHandler(XMLHandlerBase):
-    """
-    Class implementing a sax handler to read an XML project session file.
-    """
-    def __init__(self, project):
-        """
-        Constructor
-        
-        @param project Reference to the project object to store the
-                information into.
-        """
-        XMLHandlerBase.__init__(self)
-        
-        self.startDocumentSpecific = self.startDocumentSession
-        
-        self.elements.update({
-            'Session' : (self.startSession, self.defaultEndElement),
-            'MultiProject' : (self.defaultStartElement, self.endMultiProject),
-            'Project' : (self.defaultStartElement, self.endProject),
-            'Filename' : (self.startFilename, self.endFilename),
-            'ActiveWindow' : (self.startFilename, self.endFilename),
-            'Breakpoint' : (self.startBreakpoint, self.endBreakpoint),
-            'BpFilename' : (self.defaultStartElement, self.endBFilename),
-            'Linenumber' : (self.startLinenumber, self.defaultEndElement),
-            'Condition' : (self.defaultStartElement, self.endCondition),
-            'Enabled' : (self.startEnabled, self.defaultEndElement),
-            'Temporary' : (self.startTemporary, self.defaultEndElement),
-            'Count' : (self.startCount, self.defaultEndElement),
-            'Watchexpression' : (self.startWatchexpression, self.endWatchexpression),
-            'Special' : (self.defaultStartElement, self.endSpecial),
-            'CommandLine' : (self.defaultStartElement, self.endCommandLine),
-            'WorkingDirectory' : (self.defaultStartElement, self.endWorkingDirectory),
-            'Environment' : (self.defaultStartElement, self.endEnvironment),
-            'ReportExceptions' : (self.startReportExceptions, self.defaultEndElement),
-            'Exceptions' : (self.startExceptions, self.endExceptions),
-            'Exception' : (self.defaultStartElement, self.endException),
-            'IgnoredExceptions' : (self.startIgnoredExceptions, self.endIgnoredExceptions),
-            'IgnoredException' : (self.defaultStartElement, self.endIgnoredException),
-            'AutoClearShell' : (self.startAutoClearShell, self.defaultEndElement),
-            'TracePython' : (self.startTracePython, self.defaultEndElement),
-            'AutoContinue' : (self.startAutoContinue, self.defaultEndElement),
-            'Bookmark' : (self.startBookmark, self.endBookmark),
-            'BmFilename' : (self.defaultStartElement, self.endBFilename),
-            
-            ####################################################################
-            ## backward compatibility
-            ####################################################################
-            'Watchpoint' : (self.startWatchexpression, self.endWatchexpression),    # 4.0
-            'CovexcPattern' : (self.defaultStartElement, self.defaultEndElement),   # 4.3
-        })
-    
-        self.project = project
-        self.isGlobal = project is None
-        
-        self.project = e5App().getObject("Project")
-        self.multiProject = e5App().getObject("MultiProject")
-        self.vm = e5App().getObject("ViewManager")
-        self.dbg = e5App().getObject("DebugUI")
-        self.dbs = e5App().getObject("DebugServer")
-        
-    def startDocumentSession(self):
-        """
-        Handler called, when the document parsing is started.
-        """
-        if not self.isGlobal:
-            # clear all breakpoints and bookmarks first
-            # (in case we are rereading a session file)
-            files = self.project.getSources(True)
-            for file in files:
-                editor = self.vm.getOpenEditor(file)
-                if editor is not None:
-                    editor.clearBookmarks()
-            self.dbs.getBreakPointModel().deleteAll()
-        self.version = ''
-    
-    ###################################################
-    ## below follow the individual handler functions
-    ###################################################
-    
-    def endMultiProject(self):
-        """
-        Handler method for the "MultiProject" end tag.
-        """
-        self.multiProject.openMultiProject(self.buffer, False)
-        
-    def endProject(self):
-        """
-        Handler method for the "Project" end tag.
-        """
-        self.project.openProject(self.buffer, False)
-        
-    def startFilename(self, attrs):
-        """
-        Handler method for the "Filename" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.buffer = ""
-        self.cline = int(attrs.get("cline", "0"))
-        self.cindex = int(attrs.get("cindex", "0"))
-        self.zoom = int(attrs.get("zoom", "-9999"))
-        
-        folds = attrs.get("folds", "")
-        if folds:
-            self.folds = [int(f) for f in folds.split(',')]
-        else:
-            self.folds = []
-        
-    def endFilename(self):
-        """
-        Handler method for the "Filename" end tag.
-        """
-        self.vm.openFiles(self.buffer)
-        ed = self.vm.getOpenEditor(self.buffer)
-        if ed is not None:
-            if self.zoom > -9999:
-                ed.zoomTo(self.zoom)
-            if self.folds:
-                ed.recolor()
-                for line in self.folds:
-                    ed.foldLine(line - 1)
-            ed.setCursorPosition(self.cline, self.cindex)
-            ed.ensureCursorVisible()
-        
-    def startBreakpoint(self, attrs):
-        """
-        Handler method for the "Breakpoint" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.filename = ""
-        self.lineno = 0
-        self.bpCond = ""
-        self.bpTemp = False
-        self.bpEnabled = True
-        self.bpCount = 0
-        
-    def endBreakpoint(self):
-        """
-        Handler method for the "Breakpoint" end tag.
-        """
-        self.dbs.getBreakPointModel().addBreakPoint(self.filename, self.lineno,
-            (self.bpCond, self.bpTemp, self.bpEnabled, self.bpCount))
-        
-    def startWatchexpression(self, attrs):
-        """
-        Handler method for the "Watchexpression" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.bpCond = ""
-        self.bpTemp = False
-        self.bpEnabled = True
-        self.bpCount = 0
-        self.wpSpecialCond = ""
-        
-    def endWatchexpression(self):
-        """
-        Handler method for the "Watchexpression" end tag.
-        """
-        self.dbs.getWatchPointModel().addWatchPoint(self.bpCond, 
-            (self.bpTemp, self.bpEnabled, self.bpCount, self.wpSpecialCond))
-        
-    def endBFilename(self):
-        """
-        Handler method for the "BFilename" end tag.
-        """
-        self.filename = self.buffer
-        
-    def startLinenumber(self, attrs):
-        """
-        Handler method for the "Linenumber" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.lineno = int(attrs["value"])
-        
-    def endCondition(self):
-        """
-        Handler method for the "Condition" end tag.
-        """
-        cond = self.unescape(self.buffer)
-        if cond == 'None':
-            self.bpCond = ''
-        else:
-            self.bpCond = cond
-            
-    def startEnabled(self, attrs):
-        """
-        Handler method for the "Enabled" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.bpEnabled = attrs["value"]
-        if self.bpEnabled in ["True", "False"]:
-            self.bpEnabled = self.bpEnabled == "True"
-        else:
-            self.bpEnabled = bool(int(self.bpEnabled))
-        
-    def startTemporary(self, attrs):
-        """
-        Handler method for the "Temporary" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.bpTemp = attrs["value"]
-        if self.bpTemp in ["True", "False"]:
-            self.bpTemp = self.bpTemp == "True"
-        else:
-            self.bpTemp = bool(int(self.bpTemp))
-        
-    def startCount(self, attrs):
-        """
-        Handler method for the "Count" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.bpCount = int(attrs["value"])
-        
-    def endSpecial(self):
-        """
-        Handler method for the "Special" end tag.
-        """
-        self.wpSpecialCond = self.buffer
-        
-    def endCommandLine(self):
-        """
-        Handler method for the "CommandLine" end tag.
-        """
-        self.buffer = self.unescape(self.buffer)
-        self.dbg.setArgvHistory(self.buffer)
-        if not self.isGlobal:
-            self.project.dbgCmdline = self.buffer
-        
-    def endWorkingDirectory(self):
-        """
-        Handler method for the "WorkinDirectory" end tag.
-        """
-        self.dbg.setWdHistory(self.buffer)
-        if not self.isGlobal:
-            self.project.dbgWd = self.buffer
-        
-    def endEnvironment(self):
-        """
-        Handler method for the "Environment" end tag.
-        """
-        self.dbg.setEnvHistory(self.buffer)
-        if not self.isGlobal:
-            self.project.dbgEnv = self.buffer
-    
-    def startReportExceptions(self, attrs):
-        """
-        Handler method for the "ReportExceptions" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        exc = attrs.get("value", "False")
-        if exc in ["True", "False"]:
-            if exc == "True":
-                exc = True
-            else:
-                exc = False
-        else:
-            exc = bool(int(exc))
-        self.dbg.setExceptionReporting(exc)
-        if not self.isGlobal:
-            self.project.dbgReportExceptions = exc
-        
-    def startExceptions(self, attrs):
-        """
-        Handler method for the "Exceptions" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.dbgExcList = []
-        
-    def endExceptions(self):
-        """
-        Handler method for the "Exceptions" end tag.
-        """
-        self.dbg.setExcList(self.dbgExcList)
-        if not self.isGlobal:
-            self.project.dbgExcList = self.dbgExcList[:] # keep a copy
-        
-    def endException(self):
-        """
-        Handler method for the "Exception" end tag.
-        """
-        self.dbgExcList.append(self.buffer)
-        
-    def startIgnoredExceptions(self, attrs):
-        """
-        Handler method for the "IgnoredExceptions" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.dbgExcIgnoreList = []
-        
-    def endIgnoredExceptions(self):
-        """
-        Handler method for the "IgnoredExceptions" end tag.
-        """
-        self.dbg.setExcIgnoreList(self.dbgExcIgnoreList)
-        if not self.isGlobal:
-            self.project.dbgExcIgnoreList = self.dbgExcIgnoreList[:] # keep a copy
-        
-    def endIgnoredException(self):
-        """
-        Handler method for the "IgnoredException" end tag.
-        """
-        self.dbgExcIgnoreList.append(self.buffer)
-        
-    def startAutoClearShell(self, attrs):
-        """
-        Handler method for the "AutoClearShell" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        autoClearShell = attrs.get("value", "False")
-        if autoClearShell == "True":
-            autoClearShell = True
-        else:
-            autoClearShell = False
-        self.dbg.setAutoClearShell(autoClearShell)
-        if not self.isGlobal:
-            self.project.dbgAutoClearShell = autoClearShell
-        
-    def startTracePython(self, attrs):
-        """
-        Handler method for the "TracePython" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        tracePython = attrs.get("value", "False")
-        if tracePython in ["True", "False"]:
-            if tracePython == "True":
-                tracePython = True
-            else:
-                tracePython = False
-        else:
-            tracePython = bool(int(tracePython))
-        self.dbg.setTracePython(tracePython)
-        if not self.isGlobal:
-            self.project.dbgTracePython = tracePython
-        
-    def startAutoContinue(self, attrs):
-        """
-        Handler method for the "AutoContinue" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        autoContinue = attrs.get("value", "False")
-        if autoContinue == "True":
-            autoContinue = True
-        else:
-            autoContinue = False
-        self.dbg.setAutoContinue(autoContinue)
-        if not self.isGlobal:
-            self.project.dbgAutoContinue = autoContinue
-        
-    def startBookmark(self, attrs):
-        """
-        Handler method for the "Bookmark" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.filename = ""
-        self.lineno = 0
-        
-    def endBookmark(self):
-        """
-        Handler method for the "Bookmark" end tag.
-        """
-        editor = self.vm.getOpenEditor(self.filename)
-        if editor is not None:
-            editor.toggleBookmark(self.lineno)
-        
-    def startSession(self, attrs):
-        """
-        Handler method for the "Session" start tag.
-        
-        @param attrs list of tag attributes
-        """
-        self.version = attrs.get('version', sessionFileFormatVersion)
-        
-    def getVersion(self):
-        """
-        Public method to retrieve the version of the session.
-        
-        @return String containing the version number.
-        """
-        return self.version
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/E5XML/SessionReader.py	Sun Sep 12 18:37:31 2010 +0200
@@ -0,0 +1,333 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a class for reading an XML session file.
+"""
+
+from E5Gui.E5Application import e5App
+
+from .Config import sessionFileFormatVersion
+from .XMLStreamReaderBase import XMLStreamReaderBase
+
+class SessionReader(XMLStreamReaderBase):
+    """
+    Class for reading an XML session file.
+    """
+    supportedVersions = ["4.3", "4.4"]
+    
+    def __init__(self, device, isGlobal):
+        """
+        Constructor
+        
+        @param device reference to the I/O device to read from (QIODevice)
+        @param isGlobal flag indicating to read the global session (boolean).
+        """
+        XMLStreamReaderBase.__init__(self, device)
+        
+        self.version = ""
+        self.isGlobal = isGlobal
+        
+        self.project = e5App().getObject("Project")
+        self.multiProject = e5App().getObject("MultiProject")
+        self.vm = e5App().getObject("ViewManager")
+        self.dbg = e5App().getObject("DebugUI")
+        self.dbs = e5App().getObject("DebugServer")
+        
+        if not self.isGlobal:
+            # clear all breakpoints and bookmarks first
+            # (in case we are rereading a session file)
+            files = self.project.getSources(True)
+            for file in files:
+                editor = self.vm.getOpenEditor(file)
+                if editor is not None:
+                    editor.clearBookmarks()
+            self.dbs.getBreakPointModel().deleteAll()
+            self.dbs.getWatchPointModel().deleteAll()
+    
+    def readXML(self, quiet = False):
+        """
+        Public method to read and parse the XML document.
+        
+        @param quiet flag indicating quiet operations.
+                If this flag is true, no errors are reported.
+        """
+        while not self.atEnd():
+            self.readNext()
+            if self.isStartElement():
+                if self.name() == "Session":
+                    self.version = self.attribute("version", sessionFileFormatVersion)
+                    if self.version not in self.supportedVersions:
+                        self.raiseUnsupportedFormatVersion(self.version)
+                elif self.name() == "MultiProject":
+                    self.multiProject.openMultiProject(self.readElementText(), False)
+                elif self.name() == "Project":
+                    self.project.openProject(self.readElementText(), False)
+                elif self.name() == "Filenames":
+                    self.__readFilenames()
+                elif self.name() == "ActiveWindow":
+                    cline = int(self.attribute("cline", "0"))
+                    cindex = int(self.attribute("cindex", "0"))
+                    filename = self.readElementText()
+                    self.vm.openFiles(filename)
+                    ed = self.vm.getOpenEditor(filename)
+                    if ed is not None:
+                        ed.setCursorPosition(cline, cindex)
+                        ed.ensureCursorVisible()
+                elif self.name() == "Breakpoints":
+                    self.__readBreakpoints()
+                elif self.name() == "Watchexpressions":
+                    self.__readWatchexpressions()
+                elif self.name() == "DebugInfo":
+                    self.__readDebugInfo()
+                elif self.name() == "Bookmarks":
+                    self.__readBookmarks()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+        
+        if not quiet:
+            self.showErrorMessage()
+    
+    def __readFilenames(self):
+        """
+        Private method to read the file name infos.
+        """
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Filenames":
+                break
+            
+            if self.isStartElement():
+                if self.name() == "Filename":
+                    cline = int(self.attribute("cline", "0"))
+                    cindex = int(self.attribute("cindex", "0"))
+                    folds = self.attribute("folds")
+                    if folds:
+                        folds = [int(f) for f in folds.split(',')]
+                    else:
+                        folds = []
+                    zoom = int(self.attribute("zoom", "-9999"))
+                    filename = self.readElementText()
+                    
+                    self.vm.openFiles(filename)
+                    ed = self.vm.getOpenEditor(filename)
+                    if ed is not None:
+                        if zoom > -9999:
+                            ed.zoomTo(zoom)
+                        if folds:
+                            ed.recolor()
+                            for line in folds:
+                                ed.foldLine(line - 1)
+                        ed.setCursorPosition(cline, cindex)
+                        ed.ensureCursorVisible()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readBreakpoints(self):
+        """
+        Private method to read the break point infos.
+        """
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Breakpoints":
+                break
+            
+            if self.isStartElement():
+                if self.name() == "Breakpoint":
+                    self.__readBreakpoint()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readBreakpoint(self):
+        """
+        Private method to read the break point info.
+        """
+        filename = ""
+        lineno = 0
+        bpCond = ""
+        bpTemp = False
+        bpEnabled = True
+        bpCount = 0
+        
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Breakpoint":
+                self.dbs.getBreakPointModel().addBreakPoint(filename, lineno,
+                    (bpCond, bpTemp, bpEnabled, bpCount))
+                break
+            
+            if self.isStartElement():
+                if self.name() == "BpFilename":
+                    filename = self.readElementText()
+                elif self.name() == "Linenumber":
+                    lineno = int(self.attribute("value", "0"))
+                elif self.name() == "Condition":
+                    bpCond = self.readElementText()
+                    if bpCond == 'None':
+                        bpCond = ''
+                elif self.name() == "Temporary":
+                    bpTemp = self.toBool(self.attribute("value", "False"))
+                elif self.name() == "Enabled":
+                    bpEnabled = self.toBool(self.attribute("value", "True"))
+                elif self.name() == "Count":
+                    bpCount = int(self.attribute("value", "0"))
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readWatchexpressions(self):
+        """
+        Private method to read watch expression infos.
+        """
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Watchexpressions":
+                break
+            
+            if self.isStartElement():
+                if self.name() == "Watchexpression":
+                    self.__readWatchexpression()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readWatchexpression(self):
+        """
+        Private method to read the watch expression info.
+        """
+        weCond = ""
+        weTemp = False
+        weEnabled = True
+        weCount = 0
+        weSpecialCond = ""
+        
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Watchexpression":
+                self.dbs.getWatchPointModel().addWatchPoint(weCond, 
+                    (weTemp, weEnabled, weCount, weSpecialCond))
+                break
+            
+            if self.isStartElement():
+                if self.name() == "Condition":
+                    weCond = self.readElementText()
+                    if weCond == 'None':
+                        weCond = ''
+                elif self.name() == "Temporary":
+                    weTemp = self.toBool(self.attribute("value", "False"))
+                elif self.name() == "Enabled":
+                    weEnabled = self.toBool(self.attribute("value", "True"))
+                elif self.name() == "Count":
+                    weCount = int(self.attribute("value", "0"))
+                elif self.name() == "Special":
+                    weSpecialCond = self.readElementText()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readDebugInfo(self):
+        """
+        Private method to read the debug infos.
+        """
+        dbgExcList = []
+        dbgExcIgnoreList = []
+        
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement():
+                if self.name() == "DebugInfo":
+                    break
+                elif self.name() == "Exceptions":
+                    self.dbg.setExcList(dbgExcList)
+                    if not self.isGlobal:
+                        self.project.dbgExcList = dbgExcList[:]
+                elif self.name() == "IgnoredExceptions":
+                    self.dbg.setExcIgnoreList(dbgExcIgnoreList)
+                    if not self.isGlobal:
+                        self.project.dbgExcIgnoreList = dbgExcIgnoreList[:]
+            
+            if self.isStartElement():
+                if self.name() == "CommandLine":
+                    txt = self.readElementText()
+                    self.dbg.setArgvHistory(txt)
+                    if not self.isGlobal:
+                        self.project.dbgCmdline = txt
+                elif self.name() == "WorkingDirectory":
+                    txt = self.readElementText()
+                    self.dbg.setWdHistory(txt)
+                    if not self.isGlobal:
+                        self.project.dbgWd = txt
+                elif self.name() == "Environment":
+                    txt = self.readElementText()
+                    self.dbg.setEnvHistory(txt)
+                    if not self.isGlobal:
+                        self.project.dbgEnv = txt
+                elif self.name() == "ReportExceptions":
+                    exc = self.toBool(self.attribute("value", "True"))
+                    self.dbg.setExceptionReporting(exc)
+                    if not self.isGlobal:
+                        self.project.dbgReportExceptions = exc
+                elif self.name() == "Exceptions":
+                    pass    # ignore this start tag
+                elif self.name() == "Exception":
+                    dbgExcList.append(self.readElementText())
+                elif self.name() == "IgnoredExceptions":
+                    pass    # ignore this start tag
+                elif self.name() == "IgnoredException":
+                    dbgExcIgnoreList.append(self.readElementText())
+                elif self.name() == "AutoClearShell":
+                    val = self.toBool(self.attribute("value"))
+                    self.dbg.setAutoClearShell(val)
+                    if not self.isGlobal:
+                        self.project.dbgAutoClearShell = val
+                elif self.name() == "TracePython":
+                    val = self.toBool(self.attribute("value"))
+                    self.dbg.setTracePython(val)
+                    if not self.isGlobal:
+                        self.project.dbgTracePython = val
+                elif self.name() == "AutoContinue":
+                    val = self.toBool(self.attribute("value"))
+                    self.dbg.setAutoContinue(val)
+                    if not self.isGlobal:
+                        self.project.dbgAutoContinue = val
+                elif self.name() == "CovexcPattern":
+                    pass    # ignore this start tag
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readBookmarks(self):
+        """
+        Private method to read the bookmark infos.
+        """
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Bookmarks":
+                break
+            
+            if self.isStartElement():
+                if self.name() == "Bookmark":
+                    self.__readBookmark()
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
+    
+    def __readBookmark(self):
+        """
+        Private method to read the bookmark info.
+        """
+        filename = ""
+        lineno = 0
+        
+        while not self.atEnd():
+            self.readNext()
+            if self.isEndElement() and self.name() == "Bookmark":
+                editor = self.vm.getOpenEditor(filename)
+                if editor is not None:
+                    editor.toggleBookmark(lineno)
+                break
+            
+            if self.isStartElement():
+                if self.name() == "BmFilename":
+                    filename = self.readElementText()
+                elif self.name() == "Linenumber":
+                    lineno = int(self.attribute("value", "0"))
+                else:
+                    self.raiseUnexpectedStartTag(self.name())
--- a/E5XML/SessionWriter.py	Sun Sep 12 18:20:15 2010 +0200
+++ b/E5XML/SessionWriter.py	Sun Sep 12 18:37:31 2010 +0200
@@ -4,31 +4,31 @@
 #
 
 """
-Module implementing the writer class for writing an XML project session file.
+Module implementing the writer class for writing an XML session file.
 """
 
 import time
 
 from E5Gui.E5Application import e5App
 
-from .XMLWriterBase import XMLWriterBase
+from .XMLStreamWriterBase import XMLStreamWriterBase
 from .Config import sessionFileFormatVersion
 
 import Preferences
 
-class SessionWriter(XMLWriterBase):
+class SessionWriter(XMLStreamWriterBase):
     """
-    Class implementing the writer class for writing an XML project session file.
+    Class implementing the writer class for writing an XML session file.
     """
-    def __init__(self, file, projectName):
+    def __init__(self, device, projectName):
         """
         Constructor
         
-        @param file open file (like) object for writing
+        @param device reference to the I/O device to write to (QIODevice)
         @param projectName name of the project (string) or None for the
             global session
         """
-        XMLWriterBase.__init__(self, file)
+        XMLStreamWriterBase.__init__(self, device)
         
         self.name = projectName
         self.project = e5App().getObject("Project")
@@ -43,33 +43,33 @@
         """
         isGlobal = self.name is None
         
-        XMLWriterBase.writeXML(self)
+        XMLStreamWriterBase.writeXML(self)
         
-        self._write('<!DOCTYPE Session SYSTEM "Session-{0}.dtd">'.format(
+        self.writeDTD('<!DOCTYPE Session SYSTEM "Session-{0}.dtd">'.format(
             sessionFileFormatVersion))
         
         # add some generation comments
         if not isGlobal:
-            self._write("<!-- eric5 session file for project {0} -->".format(self.name))
-        self._write("<!-- This file was generated automatically, do not edit. -->")
+            self.writeComment(" eric5 session file for project {0} ".format(self.name))
+        self.writeComment(" This file was generated automatically, do not edit. ")
         if Preferences.getProject("XMLTimestamp") or isGlobal:
-            self._write("<!-- Saved: {0} -->".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
+            self.writeComment(" Saved: {0} ".format(time.strftime('%Y-%m-%d, %H:%M:%S')))
         
         # add the main tag
-        self._write('<Session version="{0}">'.format(sessionFileFormatVersion))
+        self.writeStartElement("Session")
+        self.writeAttribute("version", sessionFileFormatVersion)
         
         # step 0: save open multi project and project for the global session
         if isGlobal:
             if self.multiProject.isOpen():
-                self._write('    <MultiProject>{0}</MultiProject>'.format(
-                    self.multiProject.getMultiProjectFile()))
+                self.writeTextElement("MultiProject", 
+                    self.multiProject.getMultiProjectFile())
             if self.project.isOpen():
-                self._write('    <Project>{0}</Project>'.format(
-                    self.project.getProjectFile()))
+                self.writeTextElement("Project", self.project.getProjectFile())
         
         # step 1: save all open (project) filenames and the active window
         allOpenFiles = self.vm.getOpenFilenames()
-        self._write("  <Filenames>")
+        self.writeStartElement("Filenames")
         for of in allOpenFiles:
             if isGlobal or of.startswith(self.project.ppath):
                 ed = self.vm.getOpenEditor(of)
@@ -81,10 +81,14 @@
                     line, index = 0, 0
                     folds = ''
                     zoom = -9999
-                self._write(
-                    '    <Filename cline="{0:d}" cindex="{1:d}" folds="{2}" zoom="{3:d}">'
-                    '{4}</Filename>'.format(line, index, folds, zoom, of))
-        self._write("  </Filenames>")
+                self.writeStartElement("Filename")
+                self.writeAttribute("cline", str(line))
+                self.writeAttribute("cindex", str(index))
+                self.writeAttribute("folds", folds)
+                self.writeAttribute("zoom", str(zoom))
+                self.writeCharacters(of)
+                self.writeEndElement()
+        self.writeEndElement()
         
         aw = self.vm.getActiveName()
         if aw and aw.startswith(self.project.ppath):
@@ -93,47 +97,56 @@
                 line, index = ed.getCursorPosition()
             else:
                 line, index = 0, 0
-            self._write('  <ActiveWindow cline="{0:d}" cindex="{1:d}">{2}</ActiveWindow>'\
-                .format(line, index, aw))
+            self.writeStartElement("ActiveWindow")
+            self.writeAttribute("cline", str(line))
+            self.writeAttribute("cindex", str(index))
+            self.writeCharacters(aw)
+            self.writeEndElement()
         
         # step 2a: save all breakpoints
         allBreaks = Preferences.getProject("SessionAllBreakpoints")
         projectFiles = self.project.getSources(True)
         bpModel = self.dbs.getBreakPointModel()
-        self._write("  <Breakpoints>")
+        self.writeStartElement("Breakpoints")
         for row in range(bpModel.rowCount()):
             index = bpModel.index(row, 0)
             fname, lineno, cond, temp, enabled, count = \
                 bpModel.getBreakPointByIndex(index)[:6]
             if isGlobal or allBreaks or fname in projectFiles:
-                self._write("    <Breakpoint>")
-                self._write("      <BpFilename>{0}</BpFilename>".format(fname))
-                self._write('      <Linenumber value="{0:d}" />'.format(lineno))
-                self._write("      <Condition>{0}</Condition>".format(
-                    self.escape(str(cond))))
-                self._write('      <Temporary value="{0}" />'.format(temp))
-                self._write('      <Enabled value="{0}" />'.format(enabled))
-                self._write('      <Count value="{0:d}" />'.format(count))
-                self._write("    </Breakpoint>")
-        self._write("  </Breakpoints>")
+                self.writeStartElement("Breakpoint")
+                self.writeTextElement("BpFilename", fname)
+                self.writeEmptyElement("Linenumber")
+                self.writeAttribute("value", str(lineno))
+                self.writeTextElement("Condition", str(cond))
+                self.writeEmptyElement("Temporary")
+                self.writeAttribute("value", str(temp))
+                self.writeEmptyElement("Enabled")
+                self.writeAttribute("value", str(enabled))
+                self.writeEmptyElement("Count")
+                self.writeAttribute("value", str(count))
+                self.writeEndElement()
+        self.writeEndElement()
         
         # step 2b: save all watch expressions
-        self._write("  <Watchexpressions>")
+        self.writeStartElement("Watchexpressions")
         wpModel = self.dbs.getWatchPointModel()
         for row in range(wpModel.rowCount()):
             index = wpModel.index(row, 0)
             cond, temp, enabled, count, special = wpModel.getWatchPointByIndex(index)[:5]
-            self._write('    <Watchexpression>')
-            self._write("      <Condition>{0}</Condition>".format(self.escape(str(cond))))
-            self._write('      <Temporary value="{0}" />'.format(temp))
-            self._write('      <Enabled value="{0}" />'.format(enabled))
-            self._write('      <Count value="{0:d}" />'.format(count))
-            self._write('      <Special>{0}</Special>'.format(special))
-            self._write('    </Watchexpression>')
-        self._write('  </Watchexpressions>')
+            self.writeStartElement("Watchexpression")
+            self.writeTextElement("Condition", str(cond))
+            self.writeEmptyElement("Temporary")
+            self.writeAttribute("value", str(temp))
+            self.writeEmptyElement("Enabled")
+            self.writeAttribute("value", str(enabled))
+            self.writeEmptyElement("Count")
+            self.writeAttribute("value", str(count))
+            self.writeTextElement("Special", special)
+            self.writeEndElement()
+        self.writeEndElement()
         
         # step 3: save the debug info
-        self._write("  <DebugInfo>")
+        self.writeStartElement("DebugInfo")
         if isGlobal:
             if len(self.dbg.argvHistory):
                 dbgCmdline = str(self.dbg.argvHistory[0])
@@ -147,61 +160,62 @@
                 dbgEnv = self.dbg.envHistory[0]
             else:
                 dbgEnv = ""
-            self._write("    <CommandLine>{0}</CommandLine>"\
-                .format(self.escape(dbgCmdline)))
-            self._write("    <WorkingDirectory>{0}</WorkingDirectory>".format(dbgWd))
-            self._write("    <Environment>{0}</Environment>".format(dbgEnv))
-            self._write('    <ReportExceptions value="{0}" />'\
-                .format(self.dbg.exceptions))
-            self._write("    <Exceptions>")
+            self.writeTextElement("CommandLine", dbgCmdline)
+            self.writeTextElement("WorkingDirectory", dbgWd)
+            self.writeTextElement("Environment", dbgEnv)
+            self.writeEmptyElement("ReportExceptions")
+            self.writeAttribute("value", str(self.dbg.exceptions))
+            self.writeStartElement("Exceptions")
             for exc in self.dbg.excList:
-                self._write("      <Exception>{0}</Exception>".format(exc))
-            self._write("    </Exceptions>")
-            self._write("    <IgnoredExceptions>")
+                self.writeTextElement("Exception", exc)
+            self.writeEndElement()
+            self.writeStartElement("IgnoredExceptions")
             for iexc in self.dbg.excIgnoreList:
-                self._write("      <IgnoredException>{0}</IgnoredException>".format(iexc))
-            self._write("    </IgnoredExceptions>")
-            self._write('    <AutoClearShell value="{0}" />'\
-                .format(self.dbg.autoClearShell))
-            self._write('    <TracePython value="{0}" />'.format(self.dbg.tracePython))
-            self._write('    <AutoContinue value="{0}" />'.format(self.dbg.autoContinue))
-            self._write("    <CovexcPattern></CovexcPattern>")  # kept for compatibility
+                self.writeTextElement("IgnoredException", iexc)
+            self.writeEndElement()
+            self.writeEmptyElement("AutoClearShell")
+            self.writeAttribute("value", str(self.dbg.autoClearShell))
+            self.writeEmptyElement("TracePython")
+            self.writeAttribute("value", str(self.dbg.tracePython))
+            self.writeEmptyElement("AutoContinue")
+            self.writeAttribute("value", str(self.dbg.autoContinue))
+            self.writeEmptyElement("CovexcPattern")     # kept for compatibility
         else:
-            self._write("    <CommandLine>{0}</CommandLine>".format(
-                self.escape(str(self.project.dbgCmdline))))
-            self._write("    <WorkingDirectory>{0}</WorkingDirectory>".format(
-                self.project.dbgWd))
-            self._write("    <Environment>{0}</Environment>".format(
-                self.project.dbgEnv))
-            self._write('    <ReportExceptions value="{0}" />'.format(
-                self.project.dbgReportExceptions))
-            self._write("    <Exceptions>")
+            self.writeTextElement("CommandLine", self.project.dbgCmdline)
+            self.writeTextElement("WorkingDirectory", self.project.dbgWd)
+            self.writeTextElement("Environment", self.project.dbgEnv)
+            self.writeEmptyElement("ReportExceptions")
+            self.writeAttribute("value", str(self.project.dbgReportExceptions))
+            self.writeStartElement("Exceptions")
             for exc in self.project.dbgExcList:
-                self._write("      <Exception>{0}</Exception>".format(exc))
-            self._write("    </Exceptions>")
-            self._write("    <IgnoredExceptions>")
+                self.writeTextElement("Exception", exc)
+            self.writeEndElement()
+            self.writeStartElement("IgnoredExceptions")
             for iexc in self.project.dbgExcIgnoreList:
-                self._write("      <IgnoredException>{0}</IgnoredException>".format(iexc))
-            self._write("    </IgnoredExceptions>")
-            self._write('    <AutoClearShell value="{0}" />'.format(
-                self.project.dbgAutoClearShell))
-            self._write('    <TracePython value="{0}" />'.format(
-                self.project.dbgTracePython))
-            self._write('    <AutoContinue value="{0}" />'.format(
-                self.project.dbgAutoContinue))
-            self._write("    <CovexcPattern></CovexcPattern>")  # kept for compatibility
-        self._write("  </DebugInfo>")
+                self.writeTextElement("IgnoredException", iexc)
+            self.writeEndElement()
+            self.writeEmptyElement("AutoClearShell")
+            self.writeAttribute("value", str(self.project.dbgAutoClearShell))
+            self.writeEmptyElement("TracePython")
+            self.writeAttribute("value", str(self.project.dbgTracePython))
+            self.writeEmptyElement("AutoContinue")
+            self.writeAttribute("value", str(self.project.dbgAutoContinue))
+            self.writeEmptyElement("CovexcPattern")     # kept for compatibility
+        self.writeEndElement()
         
         # step 4: save bookmarks of all open (project) files
-        self._write("  <Bookmarks>")
+        self.writeStartElement("Bookmarks")
         for of in allOpenFiles:
             if isGlobal or of.startswith(self.project.ppath):
                 editor = self.vm.getOpenEditor(of)
                 for bookmark in editor.getBookmarks():
-                    self._write("    <Bookmark>")
-                    self._write("      <BmFilename>{0}</BmFilename>".format(of))
-                    self._write('      <Linenumber value="{0:d}" />'.format(bookmark))
-                    self._write("    </Bookmark>")
-        self._write("  </Bookmarks>")
+                    self.writeStartElement("Bookmark")
+                    self.writeTextElement("BmFilename", of)
+                    self.writeEmptyElement("Linenumber")
+                    self.writeAttribute("value", str(bookmark))
+                    self.writeEndElement()
+        self.writeEndElement()
         
-        self._write("</Session>", newline = False)
+        # add the main end tag
+        self.writeEndElement()
+        self.writeEndDocument()
--- a/Project/Project.py	Sun Sep 12 18:20:15 2010 +0200
+++ b/Project/Project.py	Sun Sep 12 18:37:31 2010 +0200
@@ -45,7 +45,7 @@
 from E5XML.ProjectWriter import ProjectWriter
 from E5XML.UserProjectHandler import UserProjectHandler
 from E5XML.UserProjectWriter import UserProjectWriter
-from E5XML.SessionHandler import SessionHandler
+from E5XML.SessionReader import SessionReader
 from E5XML.SessionWriter import SessionWriter
 from E5XML.TasksReader import TasksReader
 from E5XML.TasksWriter import TasksWriter
@@ -897,138 +897,25 @@
             return
             
         fn, ext = os.path.splitext(os.path.basename(self.pfile))
-        
-        try:
-            if ext.lower() in [".e4pz"]:
-                fn = os.path.join(self.getProjectManagementDir(), 
-                                  '{0}{1}.e4sz'.format(fn, indicator))
-                try:
-                    import gzip
-                except ImportError:
-                    if not quiet:
-                        E5MessageBox.critical(self.ui,
-                            self.trUtf8("Read project session"),
-                            self.trUtf8("""Compressed project session files not"""
-                                """ supported. The compression library is missing."""))
-                    return
-                g = gzip.open(fn, "rb")
-                f = io.StringIO(g.read().decode("utf-8"))
-                g.close()
-            else:
-                fn = os.path.join(self.getProjectManagementDir(), 
-                                  '{0}{1}.e4s'.format(fn, indicator))
-                f = open(fn, "r", encoding = "utf-8")
-            line = f.readline()
-            dtdLine = f.readline()
+        fn = os.path.join(self.getProjectManagementDir(), 
+                          '{0}{1}.e4s'.format(fn, indicator))
+        
+        f = QFile(fn)
+        if f.open(QIODevice.ReadOnly):
+            reader = SessionReader(f, False)
+            reader.readXML(quiet = quiet)
             f.close()
-        except EnvironmentError:
-            if not quiet:
-                E5MessageBox.critical(self.ui,
-                    self.trUtf8("Read project session"),
-                    self.trUtf8("<p>The project session <b>{0}</b>"
-                                " could not be read.</p>")\
-                        .format(fn))
-            return
-            
-        # now read the file
-        if line.startswith('<?xml'):
-            self.__readXMLSession(fn, dtdLine.startswith("<!DOCTYPE"), quiet)
         else:
             if not quiet:
                 E5MessageBox.critical(self.ui,
                     self.trUtf8("Read project session"),
-                    self.trUtf8("<p>The project session <b>{0}</b> has an unsupported"
-                        " format.</p>").format(fn))
-    
-    def __readXMLSession(self, fn, validating, quiet):
-        """
-        Private method to read the session data from an XML file.
-        
-        The data read is:
-            <ul>
-            <li>all open source filenames</li>
-            <li>the active window</li>
-            <li>all breakpoints</li>
-            <li>the commandline</li>
-            <li>the working directory</li>
-            <li>the exception reporting flag</li>
-            <li>the list of exception types to be highlighted</li>
-            <li>all bookmarks</li>
-            </ul>
-            
-        @param fn filename of the project session file to be read (string)
-        @param validating flag indicating a validation of the XML file is
-            requested (boolean)
-        @param quiet flag indicating quiet operations.
-            If this flag is true, no errors are reported.
-        """
-        if fn.lower().endswith("e4sz"):
-            # work around for a bug in xmlproc
-            validating = False
-        
-        parser = make_parser(validating)
-        handler = SessionHandler(self)
-        er = XMLEntityResolver()
-        eh = XMLErrorHandler()
-        
-        parser.setContentHandler(handler)
-        parser.setEntityResolver(er)
-        parser.setErrorHandler(eh)
-        
-        try:
-            if fn.lower().endswith("e4sz"):
-                try:
-                    import gzip
-                except ImportError:
-                    if not quiet:
-                        E5MessageBox.critical(self.ui,
-                            self.trUtf8("Read project session"),
-                            self.trUtf8("<p>The project session <b>{0}</b> could not"
-                                " be read.</p>").format(fn))
-                    return
-                g = gzip.open(fn, "rb")
-                f = io.StringIO(g.read().decode("utf-8"))
-                g.close()
-            else:
-                f = open(fn, "r", encoding = "utf-8")
-            try:
-                try:
-                    parser.parse(f)
-                except UnicodeEncodeError:
-                    f.seek(0)
-                    buf = io.StringIO(f.read())
-                    parser.parse(buf)
-            finally:
-                f.close()
-        except IOError:
-            if not quiet:
-                E5MessageBox.critical(self.ui,
-                    self.trUtf8("Read project session"),
                     self.trUtf8("<p>The project session file <b>{0}</b> could not be"
                         " read.</p>").format(fn))
-            return
-        except XMLFatalParseError:
-            pass
-        
-        if not quiet:
-            eh.showParseMessages()
         
     def __writeSession(self, quiet = False, indicator = ""):
         """
         Private method to write the session data to an XML file (.e4s).
         
-        The data saved is:
-            <ul>
-            <li>all open source filenames belonging to the project</li>
-            <li>the active window, if it belongs to the project</li>
-            <li>all breakpoints</li>
-            <li>the commandline</li>
-            <li>the working directory</li>
-            <li>the exception reporting flag</li>
-            <li>the list of exception types to be highlighted</li>
-            <li>all bookmarks of files belonging to the project</li>
-            </ul>
-        
         @param quiet flag indicating quiet operations.
                 If this flag is true, no errors are reported.
         @keyparam indicator indicator string (string)
@@ -1041,35 +928,14 @@
             return
         
         fn, ext = os.path.splitext(os.path.basename(self.pfile))
-        
-        try:
-            if ext.lower() == ".e4pz":
-                fn = os.path.join(self.getProjectManagementDir(), 
-                                  '{0}{1}.e4sz'.format(fn, indicator))
-                try:
-                    import gzip
-                except ImportError:
-                    if not quiet:
-                        E5MessageBox.critical(self.ui,
-                            self.trUtf8("Save project session"),
-                            self.trUtf8("""Compressed project session files not"""
-                                """ supported. The compression library is missing."""))
-                    return
-                f = io.StringIO()
-            else:
-                fn = os.path.join(self.getProjectManagementDir(), 
-                                  '{0}{1}.e4s'.format(fn, indicator))
-                f = open(fn, "w", encoding = "utf-8")
-            
+        fn = os.path.join(self.getProjectManagementDir(), 
+                          '{0}{1}.e4s'.format(fn, indicator))
+        
+        f = QFile(fn)
+        if f.open(QIODevice.WriteOnly):
             SessionWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML()
-            
-            if fn.lower().endswith("e4sz"):
-                g = gzip.open(fn, "wb")
-                g.write(f.getvalue().encode("utf-8"))
-                g.close()
             f.close()
-            
-        except IOError:
+        else:
             if not quiet:
                 E5MessageBox.critical(self.ui,
                     self.trUtf8("Save project session"),
--- a/UI/UserInterface.py	Sun Sep 12 18:20:15 2010 +0200
+++ b/UI/UserInterface.py	Sun Sep 12 18:37:31 2010 +0200
@@ -9,7 +9,6 @@
 
 import os
 import sys
-import io
 import logging
 
 from PyQt4.QtCore import *
@@ -91,13 +90,10 @@
 
 import UI.PixmapCache
 
-from E5XML.XMLUtilities import make_parser
-from E5XML.XMLErrorHandler import XMLErrorHandler, XMLFatalParseError
-from E5XML.XMLEntityResolver import XMLEntityResolver
 from E5XML.TasksReader import TasksReader
 from E5XML.TasksWriter import TasksWriter
+from E5XML.SessionReader import SessionReader
 from E5XML.SessionWriter import SessionWriter
-from E5XML.SessionHandler import SessionHandler
 
 from E5Network.E5NetworkProxyFactory import E5NetworkProxyFactory, \
     proxyAuthenticationRequired
@@ -5059,15 +5055,12 @@
         """
         Private slot to write the session data to an XML file (.e4s).
         """
-        try:
-            fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s")
-            f = open(fn, "w", encoding = "utf-8")
-            
+        fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s")
+        f = QFile(fn)
+        if f.open(QIODevice.WriteOnly):
             SessionWriter(f, None).writeXML()
-            
             f.close()
-            
-        except IOError:
+        else:
             E5MessageBox.critical(self,
                 self.trUtf8("Save session"),
                 self.trUtf8("<p>The session file <b>{0}</b> could not be written.</p>")
@@ -5077,62 +5070,24 @@
         """
         Private slot to read in the session file (.e4s)
         """
-        try:
-            fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s")
-            if not os.path.exists(fn):
-                E5MessageBox.critical(self,
-                    self.trUtf8("Read session"),
-                    self.trUtf8("<p>The session file <b>{0}</b> could not be read.</p>")\
-                        .format(fn))
-                return
-            f = open(fn, "r", encoding = "utf-8")
-            line = f.readline()
-            dtdLine = f.readline()
-            f.close()
-        except IOError:
+        fn = os.path.join(Utilities.getConfigDir(), "eric5session.e4s")
+        if not os.path.exists(fn):
             E5MessageBox.critical(self,
                 self.trUtf8("Read session"),
                 self.trUtf8("<p>The session file <b>{0}</b> could not be read.</p>")\
                     .format(fn))
             return
-            
-        # now read the file
-        if line.startswith('<?xml'):
-            parser = make_parser(dtdLine.startswith("<!DOCTYPE"))
-            handler = SessionHandler(None)
-            er = XMLEntityResolver()
-            eh = XMLErrorHandler()
-            
-            parser.setContentHandler(handler)
-            parser.setEntityResolver(er)
-            parser.setErrorHandler(eh)
-            
-            try:
-                f = open(fn, "r", encoding = "utf-8")
-                try:
-                    try:
-                        parser.parse(f)
-                    except UnicodeEncodeError:
-                        f.seek(0)
-                        buf = io.StringIO(f.read())
-                        parser.parse(buf)
-                finally:
-                    f.close()
-            except IOError:
-                E5MessageBox.critical(self,
-                    self.trUtf8("Read session"),
-                    self.trUtf8("<p>The session file <b>{0}</b> could not be read.</p>")\
-                        .format(fn))
-                return
-            except XMLFatalParseError:
-                pass
-                
-            eh.showParseMessages()
+        
+        f = QFile(fn)
+        if f.open(QIODevice.ReadOnly):
+            reader = SessionReader(f, True)
+            reader.readXML()
+            f.close()
         else:
             E5MessageBox.critical(self,
                 self.trUtf8("Read session"),
-                self.trUtf8("<p>The session file <b>{0}</b> has an unsupported"
-                    " format.</p>").format(fn))
+                self.trUtf8("<p>The session file <b>{0}</b> could not be read.</p>")\
+                    .format(fn))
     
     ##########################################################
     ## Below are slots to handle StdOut and StdErr
--- a/eric5.e4p	Sun Sep 12 18:20:15 2010 +0200
+++ b/eric5.e4p	Sun Sep 12 18:37:31 2010 +0200
@@ -718,7 +718,6 @@
     <Source>E5XML/Config.py</Source>
     <Source>E5XML/__init__.py</Source>
     <Source>E5XML/TasksWriter.py</Source>
-    <Source>E5XML/SessionHandler.py</Source>
     <Source>E5XML/UserProjectWriter.py</Source>
     <Source>E5XML/UserProjectHandler.py</Source>
     <Source>E5XML/MultiProjectWriter.py</Source>
@@ -821,6 +820,7 @@
     <Source>E5XML/TemplatesReader.py</Source>
     <Source>E5XML/HighlightingStylesReader.py</Source>
     <Source>E5XML/ShortcutsReader.py</Source>
+    <Source>E5XML/SessionReader.py</Source>
   </Sources>
   <Forms>
     <Form>PyUnit/UnittestDialog.ui</Form>

eric ide

mercurial