src/eric7/Globals/__init__.py

Mon, 07 Nov 2022 17:19:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 07 Nov 2022 17:19:58 +0100
branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9549
67295777d9fe
child 9624
b47dfa7a137d
permissions
-rw-r--r--

Corrected/acknowledged some bad import style and removed some obsolete code.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8549
diff changeset
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module defining common data to be used by all modules.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
10 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
11 # Note: Do not import any eric stuff in here!!!!!!!
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
12 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
13
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
14 import contextlib
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
15 import os
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
16 import re
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
17 import sys
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
18 import sysconfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
20 from PyQt6.QtCore import (
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9448
diff changeset
21 QT_VERSION,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
22 QByteArray,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
23 QCoreApplication,
9345
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
24 QDir,
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
25 QLibraryInfo,
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
26 QProcess,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
27 qVersion,
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
28 )
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
29
9448
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
30 try:
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
31 from eric7.eric7config import getConfig
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
32 except ImportError:
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
33 from eric7config import getConfig
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
34
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 # names of the various settings objects
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
36 settingsNameOrganization = "Eric7"
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
37 settingsNameGlobal = "eric7"
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
38 settingsNameRecent = "eric7recent"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 # key names of the various recent entries
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 recentNameMultiProject = "MultiProjects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 recentNameProject = "Projects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 recentNameFiles = "Files"
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4686
diff changeset
44 recentNameHexFiles = "HexFiles"
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
45 recentNameHosts = "Hosts"
6034
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
46 recentNameBreakpointFiles = "BreakPointFiles"
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
47 recentNameBreakpointConditions = "BreakPointConditions"
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
48 recentNameTestDiscoverHistory = "UTDiscoverHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
49 recentNameTestFileHistory = "UTFileHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
50 recentNameTestNameHistory = "UTTestnameHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
51 recentNameTestFramework = "UTTestFramework"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
52 recentNameTestEnvironment = "UTEnvironmentName"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
54 configDir = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
55
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
56
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 def isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Function to check, if this is a Windows platform.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
61 @return flag indicating Windows platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
62 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
64 return sys.platform.startswith(("win", "cygwin"))
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
65
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
66
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
67 def isMacPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
68 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
69 Function to check, if this is a Mac platform.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
71 @return flag indicating Mac platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
72 @rtype bool
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
73 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
74 return sys.platform == "darwin"
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
75
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
76
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
77 def isLinuxPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
78 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
79 Function to check, if this is a Linux platform.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
81 @return flag indicating Linux platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
82 @rtype bool
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
83 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
84 return sys.platform.startswith("linux")
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
85
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
86
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
87 def desktopName():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
88 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
89 Function to determine the name of the desktop environment used
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
90 (Linux only).
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
92 @return name of the desktop environment
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
93 @rtype str
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
94 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
95 if not isLinuxPlatform():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
96 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
97
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
98 currDesktop = os.environ.get("XDG_CURRENT_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
99 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
100 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
101
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
102 currDesktop = os.environ.get("XDG_SESSION_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
103 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
104 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
105
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
106 currDesktop = os.environ.get("GDMSESSION", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
107 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
108 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
110 currDesktop = os.environ.get("GNOME_DESKTOP_SESSION_ID", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
111 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
112 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
114 currDesktop = os.environ.get("KDE_FULL_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
115 if currDesktop:
8958
ba80dceeb560 Extended the version information to include the desktop and session type (although these are not versions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
116 if currDesktop == "true":
ba80dceeb560 Extended the version information to include the desktop and session type (although these are not versions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
117 return "KDE"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
119 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
120
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
121 currDesktop = os.environ.get("DESKTOP_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
122 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
123 return currDesktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
125 return ""
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
126
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
127
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
128 def isKdeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
129 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
130 Function to check, if the current session is a KDE desktop (Linux only).
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
132 @return flag indicating a KDE desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
133 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
134 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
135 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
136 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
138 isKDE = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
139
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
140 desktop = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141 os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
142 or os.environ.get("XDG_SESSION_DESKTOP", "").lower()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
143 or os.environ.get("DESKTOP_SESSION", "").lower()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
144 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
145 isKDE = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
146 "kde" in desktop or "plasma" in desktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
147 if desktop
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148 else bool(os.environ.get("KDE_FULL_SESSION", ""))
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
149 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
150
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
151 return isKDE
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
152
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
153
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
154 def isGnomeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
155 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
156 Function to check, if the current session is a Gnome desktop (Linux only).
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
157
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
158 @return flag indicating a Gnome desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
159 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
160 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
161 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
162 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
164 isGnome = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
165
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
166 desktop = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
167 os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
168 or os.environ.get("XDG_SESSION_DESKTOP", "").lower()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169 or os.environ.get("GDMSESSION", "").lower()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
170 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
171 isGnome = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
172 "gnome" in desktop
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173 if desktop
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
174 else bool(os.environ.get("GNOME_DESKTOP_SESSION_ID", ""))
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
175 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
176
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
177 return isGnome
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
178
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
179
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
180 def sessionType():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
181 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
182 Function to determine the name of the running session (Linux only).
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
183
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
184 @return name of the desktop environment
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
185 @rtype str
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
186 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
187 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
188 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
189
8126
e7278bf7168f Globals: fixed an issue causing an exception when some environment variables are not defined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
190 sessionType = os.environ.get("XDG_SESSION_TYPE", "").lower()
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
191 if "x11" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
192 return "X11"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
193 elif "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
194 return "Wayland"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
196 sessionType = os.environ.get("WAYLAND_DISPLAY", "").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
197 if "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
198 return "Wayland"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
200 return ""
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
201
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
202
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
203 def isWaylandSession():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
204 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
205 Function to check, if the current session is a wayland session.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
206
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
207 @return flag indicating a wayland session
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
208 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
209 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
210 return sessionType() == "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
211
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
212
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
213 def getConfigDir():
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
214 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
215 Module function to get the name of the directory storing the config data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
217 @return directory name of the config dir
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
218 @rtype str
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
220 if configDir is not None and os.path.exists(configDir):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
221 hp = configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
222 else:
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
223 cdn = ".eric7"
5823
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
224 hp = os.path.join(os.path.expanduser("~"), cdn)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
225 if not os.path.exists(hp):
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
226 os.mkdir(hp)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
227 return hp
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
228
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
229
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
230 def getInstallInfoFilePath():
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
231 """
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
232 Public method to get the path name of the install info file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
233
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
234 @return file path of the install info file
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
235 @rtype str
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
236 """
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
237 filename = "eric7install.{0}.json".format(
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
238 getConfig("ericDir")
7805
3cad282e8409 Globals: fixed an issue calculating the install info file path on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7804
diff changeset
239 .replace(":", "_")
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
240 .replace("\\", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
241 .replace("/", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
242 .replace(" ", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
243 .strip("_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
244 )
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
245 return os.path.join(getConfigDir(), filename)
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
246
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
247
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
248 def setConfigDir(d):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
249 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
250 Module function to set the name of the directory storing the config data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
251
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
252 @param d name of an existing directory
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
253 @type str
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
254 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
255 global configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
256 configDir = os.path.expanduser(d)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
257
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
258
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
259 def getPythonExecutable():
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
260 """
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
261 Function to determine the path of the (non-windowed) Python executable.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
262
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
263 @return path of the Python executable
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
264 @rtype str
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
265 """
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
266 if sys.platform.startswith("linux"):
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
267 return sys.executable
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
268 elif sys.platform == "darwin":
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
269 return sys.executable.replace("pythonw", "python")
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
270 else:
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
271 return sys.executable.replace("pythonw.exe", "python.exe")
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
272
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
273
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
274 def getPythonLibraryDirectory():
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
275 """
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
276 Function to determine the path to Python's library directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
277
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
278 @return path to the Python library directory
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
279 @rtype str
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
280 """
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
281 return sysconfig.get_path("platlib")
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
282
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
283
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
284 def getPythonScriptsDirectory():
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
285 """
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
286 Function to determine the path to Python's scripts directory.
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
287
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
288 @return path to the Python scripts directory
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
289 @rtype str
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
290 """
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
291 return sysconfig.get_path("scripts")
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
292
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
293
8459
0ae07748dbe8 Changed quite a few PyQt5 references to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8346
diff changeset
294 def getPyQt6ModulesDirectory():
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
295 """
8459
0ae07748dbe8 Changed quite a few PyQt5 references to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8346
diff changeset
296 Function to determine the path to PyQt6 modules directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
297
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
298 @return path to the PyQt6 modules directory
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
299 @rtype str
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
300 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
301 pyqtPath = os.path.join(sysconfig.get_path("platlib"), "PyQt6")
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
302 if os.path.exists(pyqtPath):
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
303 return pyqtPath
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
304
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
305 return ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
306
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
307
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
308 def getPyQtToolsPath(version=5):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
309 """
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
310 Module function to get the path of the PyQt tools.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
311
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
312 @param version PyQt major version
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
313 @type int
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
314 @return path to the PyQt tools
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
315 @rtype str
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
316 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9361
diff changeset
317 from eric7 import Preferences
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
318 from eric7.EricWidgets.EricApplication import ericApp
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
319
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
320 toolsPath = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
321
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
322 # step 1: check, if the user has configured a tools path
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
323 if version == 5:
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
324 toolsPath = Preferences.getQt("PyQtToolsDir")
9334
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
325 venvName = Preferences.getQt("PyQtVenvName")
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
326 elif version == 6:
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
327 toolsPath = Preferences.getQt("PyQt6ToolsDir")
9334
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
328 venvName = Preferences.getQt("PyQt6VenvName")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
329
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
330 # step 2: determine from used Python interpreter (pylupdate is test object)
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
331 if not toolsPath:
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
332 program = "pylupdate{0}".format(version)
9334
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
333 if venvName:
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
334 venvManager = ericApp().getObject("VirtualEnvManager")
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
335 dirName = venvManager.getVirtualenvDirectory(venvName)
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
336 else:
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
337 dirName = os.path.dirname(sys.executable)
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
338
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
339 if isWindowsPlatform():
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
340 program += ".exe"
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
341 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
342 toolsPath = dirName
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
343 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
344 toolsPath = os.path.join(dirName, "Scripts")
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
345 else:
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
346 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
347 toolsPath = dirName
9334
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
348 elif os.path.exists(os.path.join(dirName, "bin", program)):
28e30230ab28 Corrected the determination of the PyQt tools path to consider the configured virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
349 toolsPath = os.path.join(dirName, "bin")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
350
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
351 return toolsPath
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
352
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
353
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
354 def getQtBinariesPath(libexec=False):
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
355 """
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
356 Module function to get the path of the Qt binaries.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
358 @param libexec flag indicating to get the path of the executable library
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
359 (defaults to False)
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
360 @type bool (optional)
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
361 @return path of the Qt binaries
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
362 @rtype str
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
363 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9361
diff changeset
364 from eric7 import Preferences
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
365
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
366 binPath = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
367
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
368 # step 1: check, if the user has configured a tools path
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
369 qtToolsDir = Preferences.getQt("QtToolsDir")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
370 if qtToolsDir:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
371 if libexec:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
372 binPath = os.path.join(qtToolsDir, "..", "libexec")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
373 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
374 binPath = qtToolsDir
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
375 else:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
376 binPath = Preferences.getQt("QtToolsDir")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
377 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
378 binPath = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379
8327
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
380 # step 2: try the qt6_applications package
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
381 if not binPath:
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
382 with contextlib.suppress(ImportError):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
383 # if qt6-applications is not installed just go to the next step
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
384 import qt6_applications # __IGNORE_WARNING_I10__
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
385
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
386 if libexec:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
387 binPath = os.path.join(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
388 os.path.dirname(qt6_applications.__file__), "Qt", "libexec"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
389 )
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
390 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
391 binPath = os.path.join(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392 os.path.dirname(qt6_applications.__file__), "Qt", "bin"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
393 )
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
394 else:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
395 binPath = os.path.join(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
396 os.path.dirname(qt6_applications.__file__), "Qt", "bin"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
397 )
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
398 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
399 binPath = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400
9345
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
401 # step3: determine via QLibraryInfo
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
402 if not binPath:
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
403 binPath = (
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
404 QLibraryInfo.path(QLibraryInfo.LibraryPath.LibraryExecutablesPath)
9361
718bc86e1c3f Changed the handling of 'installed API files' a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9345
diff changeset
405 if libexec
718bc86e1c3f Changed the handling of 'installed API files' a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9345
diff changeset
406 else QLibraryInfo.path(QLibraryInfo.LibraryPath.BinariesPath)
9345
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
407 )
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
408
58a1e7c960b8 Extended the way the Qt executables are searched for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9336
diff changeset
409 # step 4: determine from used Python interpreter (designer is test object)
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
410 if not binPath:
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
411 program = "designer"
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
412 if isWindowsPlatform():
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
413 program += ".exe"
9420
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
414
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
415 progPath = os.path.join(getPythonScriptsDirectory(), program)
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
416 if os.path.exists(progPath):
92810aebc909 Changed the code to use sysconfig.get_path("scripts") wherever possible.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
417 binPath = getPythonScriptsDirectory()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
418
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
419 return QDir.toNativeSeparators(binPath)
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
420
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
421
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
422 ###############################################################################
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
423 ## functions for version handling
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
424 ###############################################################################
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
425
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
426
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
427 def versionToTuple(version, length=3):
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
428 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
429 Module function to convert a version string into a tuple.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
430
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
431 Note: A version string consists of non-negative decimals separated by "."
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
432 optionally followed by a suffix. Suffix is everything after the last
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
433 decimal.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
434
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
435 @param version version string
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
436 @type str
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
437 @param length desired length of the version tuple
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
438 @type int
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
439 @return version tuple without the suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
440 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
441 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
442 versionParts = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
444 # step 1: extract suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
445 version = re.split(r"[^\d.]", version)[0]
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
446 for part in version.split("."):
8240
93b8a353c4bf Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8126
diff changeset
447 with contextlib.suppress(ValueError):
7673
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
448 versionParts.append(int(part.strip()))
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
449 versionParts.extend([0] * length)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
450
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
451 return tuple(versionParts[:length])
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
452
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
453
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
454 def qVersionTuple():
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
455 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
456 Module function to get the Qt version as a tuple.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
457
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
458 @return Qt version as a tuple
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
459 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
460 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
461 return (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
462 (QT_VERSION & 0xFF0000) >> 16,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
463 (QT_VERSION & 0xFF00) >> 8,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
464 QT_VERSION & 0xFF,
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
465 )
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
466
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
467
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
468 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
469 ## functions for extended string handling
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
470 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
471
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
472
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
473 def strGroup(txt, sep, groupLen=4):
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
474 """
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
475 Module function to group a string into sub-strings separated by a
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
476 separator.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
477
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
478 @param txt text to be grouped
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
479 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
480 @param sep separator string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
481 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
482 @param groupLen length of each group
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
483 @type int
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
484 @return result string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
485 @rtype str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
486 """
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
487 groups = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
488
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
489 while len(txt) // groupLen != 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
490 groups.insert(0, txt[-groupLen:])
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
491 txt = txt[:-groupLen]
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
492 if len(txt) > 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
493 groups.insert(0, txt)
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
494 return sep.join(groups)
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
495
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
496
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
497 def strToQByteArray(txt):
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
498 """
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
499 Module function to convert a Python string into a QByteArray.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
500
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
501 @param txt Python string to be converted
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
502 @type str, bytes, bytearray
5859
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
503 @return converted QByteArray
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
504 @rtype QByteArray
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
505 """
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
506 if isinstance(txt, str):
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
507 txt = txt.encode("utf-8")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
508
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
509 return QByteArray(txt)
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
510
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
511
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
512 def dataString(size):
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
513 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
514 Module function to generate a formatted size string.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
515
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
516 @param size size to be formatted
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
517 @type int
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
518 @return formatted data string
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
519 @rtype str
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
520 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
521 if size < 1024:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
522 return QCoreApplication.translate("Globals", "{0:4.2f} Bytes").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
523 elif size < 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
524 size /= 1024
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
525 return QCoreApplication.translate("Globals", "{0:4.2f} KiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
526 elif size < 1024 * 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
527 size /= 1024 * 1024
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
528 return QCoreApplication.translate("Globals", "{0:4.2f} MiB").format(size)
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
529 elif size < 1024 * 1024 * 1024 * 1024:
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
530 size /= 1024 * 1024 * 1024
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
531 return QCoreApplication.translate("Globals", "{0:4.2f} GiB").format(size)
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
532 else:
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
533 size /= 1024 * 1024 * 1024 * 1024
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
534 return QCoreApplication.translate("Globals", "{0:4.2f} TiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
535
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
536
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
537 ###############################################################################
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
538 ## functions for converting QSetting return types to valid types
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
539 ###############################################################################
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
540
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
541
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
542 def toBool(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
543 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
544 Module function to convert a value to bool.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
545
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
546 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
547 @type str
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
548 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
549 @rtype bool
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
550 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
551 if value in ["true", "1", "True"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
552 return True
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
553 elif value in ["false", "0", "False"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
554 return False
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
555 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
556 return bool(value)
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
557
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
558
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
559 def toList(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
560 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
561 Module function to convert a value to a list.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
562
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
563 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
564 @type None, list or Any
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
565 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
566 @rtype list
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
567 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
568 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
569 return []
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
570 elif not isinstance(value, list):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
571 return [value]
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
572 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
573 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
574
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
575
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
576 def toByteArray(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
577 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
578 Module function to convert a value to a byte array.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
579
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
580 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
581 @type QByteArray or None
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
582 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
583 @rtype QByteArray
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
584 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
585 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
586 return QByteArray()
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
587 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
588 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
589
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
590
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
591 def toDict(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
592 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
593 Module function to convert a value to a dictionary.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
594
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
595 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
596 @type dict or None
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
597 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
598 @rtype dict
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
599 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
600 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
601 return {}
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
602 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
603 return value
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
604
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
605
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
606 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
607 ## functions for web browser variant detection
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
608 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
609
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
610
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
611 def getWebBrowserSupport():
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
612 """
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
613 Module function to determine the supported web browser variant.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
614
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
615 @return string indicating the supported web browser variant ("QtWebEngine",
7196
ab0a91b82b37 Removed support for QtWebKit and the old web rowser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
616 or "None")
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
617 @rtype str
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
618 """
9448
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
619 try:
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
620 from eric7.eric7config import getConfig # __IGNORE_WARNING_I101__
9448
ea215f7afab3 Fixed an issue importing the eric7config module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9420
diff changeset
621 except ImportError:
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
622 from eric7config import getConfig # __IGNORE_WARNING_I10__
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
623
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
624 scriptPath = os.path.join(getConfig("ericDir"), "Tools", "webBrowserSupport.py")
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
625 proc = QProcess()
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
626 proc.start(getPythonExecutable(), [scriptPath, qVersion()])
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
627 variant = (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
628 str(proc.readAllStandardOutput(), "utf-8", "replace").strip()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
629 if proc.waitForFinished(10000)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
630 else "None"
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
631 )
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
632 return variant
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
633
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
634
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
635 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
636 # eflag: noqa = M801

eric ide

mercurial