eric6/eric6_qregularexpression.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 6949
a5255f1ba3f0
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
4 # Copyright (c) 2013 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
8 Eric6 QRegularExpression.
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 This is the main Python script that performs the necessary initialization
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
11 of the QRegularExpression wizard module and starts the Qt event loop. This is
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
12 a standalone version of the integrated QRegularExpression wizard.
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
15 from __future__ import unicode_literals
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2736
diff changeset
16
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
17 import sys
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 import os
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
19
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
20 sys.path.insert(1, os.path.dirname(__file__))
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
21
4289
6c1ab651c9ce Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
22 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
23
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2736
diff changeset
24 try: # Only for Py2
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: 4289
diff changeset
25 import Globals.compatibility_fixes # __IGNORE_WARNING__
2791
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2736
diff changeset
26 except (ImportError):
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2736
diff changeset
27 pass
a9577f248f04 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2736
diff changeset
28
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: 4289
diff changeset
29 for arg in sys.argv[:]:
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 if arg.startswith("--config="):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import Globals
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 configDir = arg.replace("--config=", "")
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Globals.setConfigDir(configDir)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 sys.argv.remove(arg)
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: 4289
diff changeset
35 elif arg.startswith("--settings="):
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
36 from PyQt5.QtCore import QSettings
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
37 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
38 if not os.path.isdir(settingsDir):
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
39 os.makedirs(settingsDir)
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
40 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
41 settingsDir)
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
42 sys.argv.remove(arg)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 from Globals import AppInfo
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 from Toolbox import Startup
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def createMainWidget(argv):
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 Function to create the main widget.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @param argv list of commandline parameters (list of strings)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @return reference to the main widget (QWidget)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
56 from Plugins.WizardPlugins.QRegularExpressionWizard\
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
57 .QRegularExpressionWizardDialog import QRegularExpressionWizardWindow
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 return QRegularExpressionWizardWindow()
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def main():
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Main entry point into the application.
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
65 options = [
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 ("--config=configDir",
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 "use the given directory as the one containing the config files"),
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: 4289
diff changeset
68 ("--settings=settingsDir",
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
69 "use the given directory to store the settings files"),
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 ]
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
71 appinfo = AppInfo.makeAppInfo(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
72 sys.argv,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
73 "Eric6 QRegularExpression",
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
74 "",
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
75 "Regexp editor for Qt's QRegularExpression class",
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
76 options)
2736
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 res = Startup.simpleAppStartup(sys.argv,
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 appinfo,
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 createMainWidget)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 sys.exit(res)
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 if __name__ == '__main__':
86cd4d14b58e Added a wizard for the Qt5 QRegularExpression class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 main()

eric ide

mercurial