eric6/eric6_configure.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 6949
a5255f1ba3f0
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric6 Configure.
9
10 This is the main Python script to configure the eric6 IDE from the outside.
11 """
12
13 from __future__ import unicode_literals
14
15 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
16
17 try: # Only for Py2
18 import Globals.compatibility_fixes # __IGNORE_WARNING__
19 except (ImportError):
20 pass
21
22 import sys
23 import os
24
25 for arg in sys.argv[:]:
26 if arg.startswith("--config="):
27 import Globals
28 configDir = arg.replace("--config=", "")
29 Globals.setConfigDir(configDir)
30 sys.argv.remove(arg)
31 elif arg.startswith("--settings="):
32 from PyQt5.QtCore import QSettings
33 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
34 if not os.path.isdir(settingsDir):
35 os.makedirs(settingsDir)
36 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
37 settingsDir)
38 sys.argv.remove(arg)
39
40 # make ThirdParty package available as a packages repository
41 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
42 "ThirdParty", "Pygments"))
43 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
44 "ThirdParty", "EditorConfig"))
45
46 from Globals import AppInfo
47
48 from Toolbox import Startup
49
50
51 def createMainWidget(argv):
52 """
53 Function to create the main widget.
54
55 @param argv list of commandline parameters (list of strings)
56 @return reference to the main widget (QWidget)
57 """
58 from Preferences.ConfigurationDialog import ConfigurationWindow
59 w = ConfigurationWindow()
60 w.show()
61 w.showConfigurationPageByName("empty")
62 return w
63
64
65 def main():
66 """
67 Main entry point into the application.
68 """
69 options = [
70 ("--config=configDir",
71 "use the given directory as the one containing the config files"),
72 ("--settings=settingsDir",
73 "use the given directory to store the settings files"),
74 ]
75 appinfo = AppInfo.makeAppInfo(sys.argv,
76 "Eric6 Configure",
77 "",
78 "Configuration editor for eric6",
79 options)
80 res = Startup.simpleAppStartup(sys.argv,
81 appinfo,
82 createMainWidget)
83 sys.exit(res)
84
85 if __name__ == '__main__':
86 main()

eric ide

mercurial