eric6/eric6_sqlbrowser.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) 2009 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric6 SQL Browser.
9
10 This is the main Python script that performs the necessary initialization
11 of the SQL browser and starts the Qt event loop.
12 """
13
14 from __future__ import unicode_literals
15
16 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
17
18 try: # Only for Py2
19 import Globals.compatibility_fixes # __IGNORE_WARNING__
20 except (ImportError):
21 pass
22
23 import sys
24 import os
25
26 for arg in sys.argv[:]:
27 if arg.startswith("--config="):
28 import Globals
29 configDir = arg.replace("--config=", "")
30 Globals.setConfigDir(configDir)
31 sys.argv.remove(arg)
32 elif arg.startswith("--settings="):
33 from PyQt5.QtCore import QSettings
34 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
35 if not os.path.isdir(settingsDir):
36 os.makedirs(settingsDir)
37 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
38 settingsDir)
39 sys.argv.remove(arg)
40
41 from Globals import AppInfo
42
43 from Toolbox import Startup
44
45
46 def createMainWidget(argv):
47 """
48 Function to create the main widget.
49
50 @param argv list of commandline parameters (list of strings)
51 @return reference to the main widget (QWidget)
52 """
53 from SqlBrowser.SqlBrowser import SqlBrowser
54
55 if len(argv) > 1:
56 connections = argv[1:]
57 else:
58 connections = []
59
60 browser = SqlBrowser(connections)
61 return browser
62
63
64 def main():
65 """
66 Main entry point into the application.
67 """
68 options = [
69 ("--config=configDir",
70 "use the given directory as the one containing the config files"),
71 ("--settings=settingsDir",
72 "use the given directory to store the settings files"),
73 ]
74 appinfo = AppInfo.makeAppInfo(sys.argv,
75 "Eric6 SQL Browser",
76 "connection",
77 "SQL browser",
78 options)
79 res = Startup.simpleAppStartup(sys.argv,
80 appinfo,
81 createMainWidget)
82 sys.exit(res)
83
84 if __name__ == '__main__':
85 main()

eric ide

mercurial