eric6/Preferences/__init__.py

branch
multi_processing
changeset 7646
39e3db2b4936
parent 7627
812ee8c0a91a
parent 7637
c878e8255972
child 7802
eefe954f01e8
--- a/eric6/Preferences/__init__.py	Wed Jun 17 17:14:12 2020 +0200
+++ b/eric6/Preferences/__init__.py	Sun Jul 05 11:11:24 2020 +0200
@@ -17,6 +17,7 @@
 """
 
 
+import ast
 import os
 import fnmatch
 import shutil
@@ -81,12 +82,8 @@
         "SuppressClientExit": False,
         "BreakAlways": False,
         "ShowExceptionInShell": True,
-        "Python2VirtualEnv": "",
         "Python3VirtualEnv": "",
         "RubyInterpreter": "",
-        "DebugClientType": "standard",
-        # supported "standard", "custom"
-        "DebugClient": "",
         "DebugClientType3": "standard",
         # supported "standard", "custom"
         "DebugClient3": "",
@@ -108,8 +105,6 @@
         "BgColorNew": QColor("#28FFEEAA"),
         "BgColorChanged": QColor("#2870FF66"),
         "AllowedHosts": ["127.0.0.1", "::1%0"],
-        # space separated list of Python2 extensions
-        "PythonExtensions": ".py2 .pyw2 .ptl",
         # space separated list of Python3 extensions
         "Python3Extensions": ".py .pyw .py3 .pyw3",
         # Global Multiprocess Debugging Support
@@ -471,7 +466,7 @@
         
         "DefaultEncoding": "utf-8",
         "DefaultOpenFilter": QCoreApplication.translate(
-            'Lexers', 'Python Files (*.py *.py2 *.py3)'),
+            'Lexers', 'Python Files (*.py *.py3)'),
         "DefaultSaveFilter": QCoreApplication.translate(
             'Lexers', "Python3 Files (*.py)"),
         "AdditionalOpenFilters": [],
@@ -807,23 +802,6 @@
     
     # defaults for the project browser flags settings
     projectBrowserFlagsDefaults = {
-        # deprecated
-        "Qt4": (
-            SourcesBrowserFlag |
-            FormsBrowserFlag |
-            ResourcesBrowserFlag |
-            TranslationsBrowserFlag |
-            InterfacesBrowserFlag |
-            OthersBrowserFlag |
-            ProtocolsBrowserFlag),
-        # deprecated
-        "Qt4C": (
-            SourcesBrowserFlag |
-            ResourcesBrowserFlag |
-            TranslationsBrowserFlag |
-            InterfacesBrowserFlag |
-            OthersBrowserFlag |
-            ProtocolsBrowserFlag),
         "PyQt5": (
             SourcesBrowserFlag |
             FormsBrowserFlag |
@@ -857,21 +835,6 @@
             InterfacesBrowserFlag |
             OthersBrowserFlag |
             ProtocolsBrowserFlag),
-        "PySide": (
-            SourcesBrowserFlag |
-            FormsBrowserFlag |
-            ResourcesBrowserFlag |
-            TranslationsBrowserFlag |
-            InterfacesBrowserFlag |
-            OthersBrowserFlag |
-            ProtocolsBrowserFlag),
-        "PySideC": (
-            SourcesBrowserFlag |
-            ResourcesBrowserFlag |
-            TranslationsBrowserFlag |
-            InterfacesBrowserFlag |
-            OthersBrowserFlag |
-            ProtocolsBrowserFlag),
         "PySide2": (
             SourcesBrowserFlag |
             FormsBrowserFlag |
@@ -905,12 +868,8 @@
     helpDefaults = {
         "CustomViewer": "",
         "PythonDocDir": "",
-        "Python2DocDir": "",
-        "Qt4DocDir": "",
         "Qt5DocDir": "",
-        "PyQt4DocDir": "",
         "PyQt5DocDir": "",
-        "PySideDocDir": "",
         "PySide2DocDir": "",
         "EricDocDir": "",
     }
@@ -1621,7 +1580,6 @@
         # backward compatibility fot Qt < 5.10
         pass
     
-    # Avoid nasty behavior of QSettings in combination with Py2
     Prefs.settings.value("UI/SingleApplicationMode")
     
 
@@ -1714,9 +1672,9 @@
     @param prefClass preferences class used as the storage area
     @return a tuple defining the variables filter
     """
-    localsFilter = eval(prefClass.settings.value(
+    localsFilter = ast.literal_eval(prefClass.settings.value(
         "Variables/LocalsFilter", prefClass.varDefaults["LocalsFilter"]))
-    globalsFilter = eval(prefClass.settings.value(
+    globalsFilter = ast.literal_eval(prefClass.settings.value(
         "Variables/GlobalsFilter", prefClass.varDefaults["GlobalsFilter"]))
     return (localsFilter, globalsFilter)
     
@@ -1763,10 +1721,8 @@
                 "Debugger/" + key, prefClass.debuggerDefaults[key]))
     elif key in ["PythonInterpreter", "Python3Interpreter"]:
         # This code is here to ensure backward compatibility.
-        if key == "PythonInterpreter":
-            newKey = "Python2VirtualEnv"
-        else:
-            newKey = "Python3VirtualEnv"
+        # Keep "PythonInterpreter" for backward compatibility.
+        newKey = "Python3VirtualEnv"
         venvName = prefClass.settings.value(
             "Debugger/" + newKey, prefClass.debuggerDefaults[newKey])
         if venvName:
@@ -1780,11 +1736,9 @@
         else:
             interpreter = ""
         if not interpreter:
-            pyVersion = 2 if key == "PythonInterpreter" else 3
-            if sys.version_info[0] == pyVersion:
-                return sys.executable
+            return sys.executable
         return interpreter
-    elif key in ["DebugClientType", "DebugClientType3"]:
+    elif key == "DebugClientType3":
         debugClientType = prefClass.settings.value(
             "Debugger/" + key, prefClass.debuggerDefaults[key])
         # Correct obsolete entry "threaded"
@@ -1792,6 +1746,12 @@
             return "standard"
         else:
             return debugClientType
+    elif key == "PythonExtensions":
+        # we don't support Python2 anymore
+        return ""
+    elif key == "Python2VirtualEnv":
+        # we don't support Python2 anymore
+        return ""
     else:
         return prefClass.settings.value(
             "Debugger/" + key, prefClass.debuggerDefaults[key])
@@ -1816,7 +1776,11 @@
     @param prefClass preferences class used as the storage area
     @return the requested debugger setting
     """
-    if key in ["PythonExtensions", "Python3Extensions"]:
+    if key == "PythonExtensions":
+        # we don't support Python2 anymore
+        return []
+    
+    if key == "Python3Extensions":
         exts = []
         for ext in getDebugger(key, prefClass).split():
             if ext.startswith("."):
@@ -1836,7 +1800,7 @@
     @param value the value to be set
     @param prefClass preferences class used as the storage area
     """
-    if key in ["PythonExtensions", "Python3Extensions"]:
+    if key == "Python3Extensions":
         setDebugger(key, value, prefClass)
 
 
@@ -2633,7 +2597,7 @@
     else:
         return prefClass.settings.value(
             "MultiProject/" + key, prefClass.multiProjectDefaults[key])
-    
+
 
 def setMultiProject(key, value, prefClass=Prefs):
     """
@@ -2644,24 +2608,7 @@
     @param prefClass preferences class used as the storage area
     """
     prefClass.settings.setValue("MultiProject/" + key, value)
-    
 
-def getQt4DocDir(prefClass=Prefs):
-    """
-    Module function to retrieve the Qt4DocDir setting.
-    
-    @param prefClass preferences class used as the storage area
-    @return the requested Qt4DocDir setting (string)
-    """
-    s = prefClass.settings.value(
-        "Help/Qt4DocDir", prefClass.helpDefaults["Qt4DocDir"])
-    if s == "":
-        s = os.getenv("QT4DOCDIR", "")
-    if s == "":
-        s = os.path.join(
-            QLibraryInfo.location(QLibraryInfo.DocumentationPath), "html")
-    return s
-    
 
 def getQt5DocDir(prefClass=Prefs):
     """

eric ide

mercurial