src/eric7/EricXML/SessionReader.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/EricXML/SessionReader.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/EricXML/SessionReader.py	Wed Jul 13 14:55:47 2022 +0200
@@ -17,30 +17,30 @@
     """
     Class for reading an XML session file.
     """
-    supportedVersions = ["4.3", "4.4", "5.0", "6.0", "6.1", "6.2", "6.3",
-                         "6.4"]
-    
+
+    supportedVersions = ["4.3", "4.4", "5.0", "6.0", "6.1", "6.2", "6.3", "6.4"]
+
     def __init__(self, device, isGlobal):
         """
         Constructor
-        
+
         @param device reference to the I/O device to read from
         @type QIODevice
         @param isGlobal flag indicating to read the global session
         @type bool
         """
         XMLStreamReaderBase.__init__(self, device)
-        
+
         self.version = ""
         self.isGlobal = isGlobal
-        
+
         self.project = ericApp().getObject("Project")
         self.projectBrowser = ericApp().getObject("ProjectBrowser")
         self.multiProject = ericApp().getObject("MultiProject")
         self.vm = ericApp().getObject("ViewManager")
         self.dbg = ericApp().getObject("DebugUI")
         self.dbs = ericApp().getObject("DebugServer")
-        
+
         if not self.isGlobal:
             # clear all breakpoints and bookmarks first
             # (in case we are rereading a session file)
@@ -51,11 +51,11 @@
                     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.
         @type bool
@@ -64,13 +64,11 @@
             self.readNext()
             if self.isStartElement():
                 if self.name() == "Session":
-                    self.version = self.attribute(
-                        "version", sessionFileFormatVersion)
+                    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)
+                    self.multiProject.openMultiProject(self.readElementText(), False)
                 elif self.name() == "Project":
                     self.project.openProject(self.readElementText(), False)
                 elif self.name() == "Filenames":
@@ -101,10 +99,10 @@
                     self.vm.setSplitCount(splitCount)
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-        
+
         if not quiet:
             self.showErrorMessage()
-    
+
     def __readFilenames(self):
         """
         Private method to read the file name infos.
@@ -114,14 +112,14 @@
             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) - 1 for f in folds.split(',')]
+                        folds = [int(f) - 1 for f in folds.split(",")]
                     else:
                         folds = []
                     zoom = int(self.attribute("zoom", "-9999"))
@@ -129,15 +127,19 @@
                     splitIndex = int(self.attribute("splitindex", "0"))
                     editorIndex = int(self.attribute("editorindex", "-1"))
                     filename = self.readElementText()
-                    
+
                     if cloned and filename in editorDict:
                         editor = editorDict[filename]
                         ed = self.vm.newEditorView(
-                            filename, editor, editor.getFileType(),
-                            indexes=(splitIndex, editorIndex))
+                            filename,
+                            editor,
+                            editor.getFileType(),
+                            indexes=(splitIndex, editorIndex),
+                        )
                     else:
                         ed = self.vm.openSourceFile(
-                            filename, indexes=(splitIndex, editorIndex))
+                            filename, indexes=(splitIndex, editorIndex)
+                        )
                         editorDict[filename] = ed
                     if ed is not None:
                         if zoom > -9999:
@@ -149,7 +151,7 @@
                         ed.ensureCursorVisible()
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-    
+
     def __readBreakpoints(self):
         """
         Private method to read the break point infos.
@@ -158,13 +160,13 @@
             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.
@@ -175,14 +177,15 @@
         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))
+                    filename, lineno, (bpCond, bpTemp, bpEnabled, bpCount)
+                )
                 break
-            
+
             if self.isStartElement():
                 if self.name() == "BpFilename":
                     filename = self.readElementText()
@@ -190,8 +193,8 @@
                     lineno = int(self.attribute("value", "0"))
                 elif self.name() == "Condition":
                     bpCond = self.readElementText()
-                    if bpCond == 'None':
-                        bpCond = ''
+                    if bpCond == "None":
+                        bpCond = ""
                 elif self.name() == "Temporary":
                     bpTemp = self.toBool(self.attribute("value", "False"))
                 elif self.name() == "Enabled":
@@ -200,7 +203,7 @@
                     bpCount = int(self.attribute("value", "0"))
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-    
+
     def __readWatchexpressions(self):
         """
         Private method to read watch expression infos.
@@ -209,13 +212,13 @@
             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.
@@ -225,19 +228,20 @@
         weEnabled = True
         weCount = 0
         weSpecialCond = ""
-        
+
         while not self.atEnd():
             self.readNext()
             if self.isEndElement() and self.name() == "Watchexpression":
                 self.dbs.getWatchPointModel().addWatchPoint(
-                    weCond, weSpecialCond, (weTemp, weEnabled, weCount))
+                    weCond, weSpecialCond, (weTemp, weEnabled, weCount)
+                )
                 break
-            
+
             if self.isStartElement():
                 if self.name() == "Condition":
                     weCond = self.readElementText()
-                    if weCond == 'None':
-                        weCond = ''
+                    if weCond == "None":
+                        weCond = ""
                 elif self.name() == "Temporary":
                     weTemp = self.toBool(self.attribute("value", "False"))
                 elif self.name() == "Enabled":
@@ -248,14 +252,14 @@
                     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():
@@ -269,11 +273,10 @@
                     self.dbg.setExcIgnoreList(dbgExcIgnoreList)
                     if not self.isGlobal:
                         self.project.dbgExcIgnoreList = dbgExcIgnoreList[:]
-            
+
             if self.isStartElement():
-                if self.name() in ("Exceptions", "IgnoredExceptions",
-                                   "CovexcPattern"):
-                    pass    # ignore these start tags
+                if self.name() in ("Exceptions", "IgnoredExceptions", "CovexcPattern"):
+                    pass  # ignore these start tags
                 elif self.name() == "VirtualEnv":
                     txt = self.readElementText()
                     self.dbg.lastUsedVenvName = txt
@@ -341,7 +344,7 @@
                         self.project.dbgGlobalConfigOverride = configOverride
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-    
+
     def __readBookmarks(self):
         """
         Private method to read the bookmark infos.
@@ -350,20 +353,20 @@
             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":
@@ -371,7 +374,7 @@
                 if editor is not None:
                     editor.toggleBookmark(lineno)
                 break
-            
+
             if self.isStartElement():
                 if self.name() == "BmFilename":
                     filename = self.readElementText()
@@ -379,7 +382,7 @@
                     lineno = int(self.attribute("value", "0"))
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-    
+
     def __readProjectBrowserStates(self):
         """
         Private method to read the project browser state infos.
@@ -388,7 +391,7 @@
             self.readNext()
             if self.isEndElement() and self.name() == "ProjectBrowserStates":
                 break
-            
+
             if self.isStartElement():
                 if self.name() == "ProjectBrowserState":
                     browserName = self.attribute("name", "")
@@ -397,25 +400,24 @@
                     self.__readProjectBrowserState(browserName)
                 else:
                     self.raiseUnexpectedStartTag(self.name())
-        
+
     def __readProjectBrowserState(self, browserName):
         """
         Private method to read the project browser state info.
-        
+
         @param browserName name of the project browser
         @type str
         """
         expandedNames = []
-        
+
         while not self.atEnd():
             self.readNext()
             if self.isEndElement() and self.name() == "ProjectBrowserState":
-                projectBrowser = self.projectBrowser.getProjectBrowser(
-                    browserName)
+                projectBrowser = self.projectBrowser.getProjectBrowser(browserName)
                 if projectBrowser is not None:
                     projectBrowser.expandItemsByName(expandedNames)
                 break
-            
+
             if self.isStartElement():
                 if self.name() == "ExpandedItemName":
                     itemName = self.readElementText()

eric ide

mercurial