eric6/Utilities/PySideImporter.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7639
422fd05e9c91
child 7908
33afc8e96e19
child 7924
8a96736d465e
permissions
-rw-r--r--

Performed some more code cleanup.

1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
3 # Copyright (c) 2011 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
7 Module to check for the presence of PySide2 by importing it.
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import sys
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 if __name__ == "__main__":
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
13 pySideVariant = "2"
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
14 if len(sys.argv) == 2:
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
15 pySideVariant = sys.argv[1].replace("-", "")
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
16
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
17 if pySideVariant == "1":
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
18 # no PySide support anymore
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
19 ret = 1
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
20
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
21 elif pySideVariant == "2":
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
22 try:
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
23 import PySide2 # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
24 ret = 0
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
25 except ImportError:
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
26 ret = 1
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
27
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
28 else:
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 ret = 1
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 sys.exit(ret)

eric ide

mercurial