eric6/Project/Project.py

branch
jsonfiles
changeset 8009
29818ac4853c
parent 8006
c4110b8b5931
child 8010
7ce2b8bb0d9b
diff -r c4110b8b5931 -r 29818ac4853c eric6/Project/Project.py
--- a/eric6/Project/Project.py	Mon Jan 25 20:07:51 2021 +0100
+++ b/eric6/Project/Project.py	Wed Jan 27 15:09:20 2021 +0100
@@ -45,6 +45,8 @@
 from .UserProjectFile import UserProjectFile
 from .DebuggerPropertiesFile import DebuggerPropertiesFile
 
+from Sessions.SessionFile import SessionFile
+
 
 class Project(QObject):
     """
@@ -191,6 +193,7 @@
         self.__projectFile = ProjectFile(self)
         self.__userProjectFile = UserProjectFile(self)
         self.__debuggerPropertiesFile = DebuggerPropertiesFile(self)
+        self.__sessionFile = SessionFile(False)
         
         self.recent = []
         self.__loadRecent()
@@ -447,6 +450,8 @@
         self.dbgAutoClearShell = True
         self.dbgTracePython = False
         self.dbgAutoContinue = True
+        self.dbgEnableMultiprocess = True
+        self.dbgMultiprocessNoDebug = ""
         
         self.pdata = {
             "DESCRIPTION": "",
@@ -950,15 +955,15 @@
         if self.pfile is None:
             return
         
-        fn, ext = os.path.splitext(os.path.basename(self.pfile))
-        fn = os.path.join(self.getProjectManagementDir(), '{0}.eqj'.format(fn))
+        fn1, ext = os.path.splitext(os.path.basename(self.pfile))
+        fn = os.path.join(self.getProjectManagementDir(), '{0}.eqj'.format(fn1))
         if os.path.exists(fn):
             # try the new JSON based format first
             self.__userProjectFile.readFile(fn)
         else:
             # try the old XML based format second
             fn = os.path.join(self.getProjectManagementDir(),
-                              '{0}.e4q'.format(fn))
+                              '{0}.e4q'.format(fn1))
             if os.path.exists(fn):
                 f = QFile(fn)
                 if f.open(QIODevice.ReadOnly):
@@ -997,9 +1002,9 @@
         else:
             fn, ext = os.path.splitext(os.path.basename(self.pfile))
             fn_new = os.path.join(self.getProjectManagementDir(),
-                                  '{0}.e5s'.format(fn))
+                                  '{0}.esj'.format(fn))
             fn_old = os.path.join(self.getProjectManagementDir(),
-                                  '{0}.e4s'.format(fn))
+                                  '{0}.e5s'.format(fn))
             enable = os.path.exists(fn_new) or os.path.exists(fn_old)
         self.sessActGrp.findChild(
             QAction, "project_load_session").setEnabled(enable)
@@ -1009,50 +1014,53 @@
     @pyqtSlot()
     def __readSession(self, quiet=False, indicator=""):
         """
-        Private method to read in the project session file (.e5s or .e4s).
+        Private method to read in the project session file (.esj or .e5s).
         
         @param quiet flag indicating quiet operations.
                 If this flag is true, no errors are reported.
         @param indicator indicator string (string)
         """
-        # TODO: read project session
         if self.pfile is None:
             if not quiet:
                 E5MessageBox.critical(
                     self.ui,
-                    self.tr("Read project session"),
+                    self.tr("Read Project Session"),
                     self.tr("Please save the project first."))
             return
             
         fn1, ext = os.path.splitext(os.path.basename(self.pfile))
         fn = os.path.join(self.getProjectManagementDir(),
-                          '{0}{1}.e5s'.format(fn1, indicator))
-        if not os.path.exists(fn):
+                          '{0}{1}.esj'.format(fn1, indicator))
+        if os.path.exists(fn):
+            # try the new JSON based format first
+            self.__sessionFile.readFile(fn)
+        else:
+            # try the old XML based format second
             fn = os.path.join(self.getProjectManagementDir(),
-                              '{0}{1}.e4s'.format(fn1, indicator))
-        
-        f = QFile(fn)
-        if f.open(QIODevice.ReadOnly):
-            from E5XML.SessionReader import SessionReader
-            reader = SessionReader(f, False)
-            reader.readXML(quiet=quiet)
-            f.close()
-        else:
-            if not quiet:
-                E5MessageBox.critical(
-                    self.ui,
-                    self.tr("Read project session"),
-                    self.tr(
-                        "<p>The project session file <b>{0}</b> could not be"
-                        " read.</p>").format(fn))
+                              '{0}{1}.e5s'.format(fn1, indicator))
+            if os.path.exists(fn):
+                f = QFile(fn)
+                if f.open(QIODevice.ReadOnly):
+                    from E5XML.SessionReader import SessionReader
+                    reader = SessionReader(f, False)
+                    reader.readXML(quiet=quiet)
+                    f.close()
+                else:
+                    if not quiet:
+                        E5MessageBox.critical(
+                            self.ui,
+                            self.tr("Read project session"),
+                            self.tr(
+                                "<p>The project session file <b>{0}</b> could"
+                                " not be read.</p>").format(fn))
         
     @pyqtSlot()
     def __writeSession(self, quiet=False, indicator=""):
         """
-        Private method to write the session data to an XML file (.e5s).
+        Private method to write the session data to an XML file (.esj).
         
         @param quiet flag indicating quiet operations.
-                If this flag is true, no errors are reported.
+            If this flag is true, no errors are reported.
         @param indicator indicator string (string)
         """
         # TODO: write project session
@@ -1060,29 +1068,16 @@
             if not quiet:
                 E5MessageBox.critical(
                     self.ui,
-                    self.tr("Save project session"),
+                    self.tr("Save Project Session"),
                     self.tr("Please save the project first."))
             return
         
         fn, ext = os.path.splitext(os.path.basename(self.pfile))
         fn = os.path.join(self.getProjectManagementDir(),
-                          '{0}{1}.e5s'.format(fn, indicator))
-        
-        f = QFile(fn)
-        if f.open(QIODevice.WriteOnly):
-            from E5XML.SessionWriter import SessionWriter
-            SessionWriter(
-                f, os.path.splitext(os.path.basename(fn))[0]).writeXML()
-            f.close()
-        else:
-            if not quiet:
-                E5MessageBox.critical(
-                    self.ui,
-                    self.tr("Save project session"),
-                    self.tr(
-                        "<p>The project session file <b>{0}</b> could not be"
-                        " written.</p>").format(fn))
-        
+                          '{0}{1}.esj'.format(fn, indicator))
+        
+        self.__sessionFile.writeFile(fn)
+    
     def __deleteSession(self):
         """
         Private method to delete the session file.
@@ -1206,16 +1201,16 @@
                     self.tr("Please save the project first."))
             return
         
-        fn, ext = os.path.splitext(os.path.basename(self.pfile))
-        fn = os.path.join(self.getProjectManagementDir(), '{0}.edj'.format(fn))
+        fn1, ext = os.path.splitext(os.path.basename(self.pfile))
+        fn = os.path.join(self.getProjectManagementDir(),
+                          '{0}.edj'.format(fn1))
         if os.path.exists(fn):
             # try the new JSON based format first
             self.__debuggerPropertiesFile.readFile(fn)
         else:
             # try the old XML based format second
-            fn, ext = os.path.splitext(os.path.basename(self.pfile))
             fn = os.path.join(self.getProjectManagementDir(),
-                              '{0}.e4d'.format(fn))
+                              '{0}.e4d'.format(fn1))
             
             f = QFile(fn)
             if f.open(QIODevice.ReadOnly):
@@ -1344,7 +1339,8 @@
     
     def setDbgInfo(self, venvName, argv, wd, env, excReporting, excList,
                    excIgnoreList, autoClearShell, tracePython=None,
-                   autoContinue=None):
+                   autoContinue=None, enableMultiprocess=None,
+                   multiprocessNoDebug=None):
         """
         Public method to set the debugging information.
         
@@ -1371,6 +1367,12 @@
         @param autoContinue flag indicating, that the debugger should not
             stop at the first executable line
         @type bool
+        @param enableMultiprocess flag indicating, that the debugger should
+            run in multi process mode
+        @type bool
+        @param multiprocessNoDebug list of programs not to be debugged in
+            multi process mode
+        @type str
         """
         self.dbgVirtualEnv = venvName
         self.dbgCmdline = argv
@@ -1384,6 +1386,10 @@
             self.dbgTracePython = tracePython
         if autoContinue is not None:
             self.dbgAutoContinue = autoContinue
+        if enableMultiprocess is not None:
+            self.dbgEnableMultiprocess = enableMultiprocess
+        if multiprocessNoDebug is not None:
+            self.dbgMultiprocessNoDebug = multiprocessNoDebug
     
     def getTranslationPattern(self):
         """

eric ide

mercurial