1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 Eric5 Web Browser |
|
9 |
|
10 This is the main Python script that performs the necessary initialization |
|
11 of the web browser and starts the Qt event loop. This is a standalone version |
|
12 of the integrated helpviewer. |
|
13 """ |
|
14 |
|
15 import sys |
|
16 import os |
|
17 |
|
18 for arg in sys.argv: |
|
19 if arg.startswith("--config="): |
|
20 import Utilities |
|
21 configDir = arg.replace("--config=", "") |
|
22 Utilities.setConfigDir(configDir) |
|
23 sys.argv.remove(arg) |
|
24 break |
|
25 |
|
26 # make ThirdParty package available as a packages repository |
|
27 try: |
|
28 import pygments # __IGNORE_WARNING__ |
|
29 except ImportError: |
|
30 sys.path.insert(2, os.path.join(os.path.dirname(__file__), "ThirdParty", "Pygments")) |
|
31 |
|
32 from Utilities import Startup |
|
33 import Utilities |
|
34 |
|
35 def createMainWidget(argv): |
|
36 """ |
|
37 Function to create the main widget. |
|
38 |
|
39 @param argv list of commandline parameters (list of strings) |
|
40 @return reference to the main widget (QWidget) |
|
41 """ |
|
42 from Helpviewer.HelpWindow import HelpWindow |
|
43 |
|
44 searchWord = None |
|
45 for arg in reversed(argv): |
|
46 if arg.startswith("--search="): |
|
47 searchWord = argv[1].split("=", 1)[1] |
|
48 argv.remove(arg) |
|
49 elif arg.startswith("--"): |
|
50 argv.remove(arg) |
|
51 |
|
52 try: |
|
53 home = argv[1] |
|
54 except IndexError: |
|
55 home = "" |
|
56 |
|
57 help = HelpWindow(home, '.', None, 'help viewer', searchWord = searchWord) |
|
58 return help |
|
59 |
|
60 def main(): |
|
61 """ |
|
62 Main entry point into the application. |
|
63 """ |
|
64 options = [\ |
|
65 ("--config=configDir", |
|
66 "use the given directory as the one containing the config files"), |
|
67 ("--search=word", "search for the given word") |
|
68 ] |
|
69 appinfo = Startup.makeAppInfo(sys.argv, |
|
70 "Eric5 web browser", |
|
71 "file", |
|
72 "web browser", |
|
73 options) |
|
74 |
|
75 if not Utilities.checkBlacklistedVersions(): |
|
76 sys.exit(100) |
|
77 |
|
78 res = Startup.simpleAppStartup(sys.argv, |
|
79 appinfo, |
|
80 createMainWidget) |
|
81 sys.exit(res) |
|
82 |
|
83 if __name__ == '__main__': |
|
84 main() |
|