12 """ |
12 """ |
13 |
13 |
14 import sys |
14 import sys |
15 import os |
15 import os |
16 |
16 |
17 sys.path.insert(1, os.path.join( |
17 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")) |
18 os.path.dirname(__file__), "..", "..", "..", "..")) |
|
19 # four times up is the eric7 package directory |
18 # four times up is the eric7 package directory |
20 |
19 |
21 for arg in sys.argv[:]: |
20 for arg in sys.argv[:]: |
22 if arg.startswith("--config="): |
21 if arg.startswith("--config="): |
23 import Globals |
22 import Globals |
|
23 |
24 configDir = arg.replace("--config=", "") |
24 configDir = arg.replace("--config=", "") |
25 Globals.setConfigDir(configDir) |
25 Globals.setConfigDir(configDir) |
26 sys.argv.remove(arg) |
26 sys.argv.remove(arg) |
27 elif arg.startswith("--settings="): |
27 elif arg.startswith("--settings="): |
28 from PyQt6.QtCore import QSettings |
28 from PyQt6.QtCore import QSettings |
|
29 |
29 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
30 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
30 if not os.path.isdir(settingsDir): |
31 if not os.path.isdir(settingsDir): |
31 os.makedirs(settingsDir) |
32 os.makedirs(settingsDir) |
32 QSettings.setPath( |
33 QSettings.setPath( |
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) |
34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir |
|
35 ) |
34 sys.argv.remove(arg) |
36 sys.argv.remove(arg) |
35 |
37 |
36 from Globals import AppInfo |
38 from Globals import AppInfo |
37 |
39 |
38 from Toolbox import Startup |
40 from Toolbox import Startup |
39 |
41 |
40 |
42 |
41 def createMainWidget(argv): |
43 def createMainWidget(argv): |
42 """ |
44 """ |
43 Function to create the main widget. |
45 Function to create the main widget. |
44 |
46 |
45 @param argv list of commandline parameters |
47 @param argv list of commandline parameters |
46 @type list of str |
48 @type list of str |
47 @return reference to the main widget or None in case of an error |
49 @return reference to the main widget or None in case of an error |
48 @rtype QWidget or None |
50 @rtype QWidget or None |
49 """ |
51 """ |
50 if len(argv) > 1: |
52 if len(argv) > 1: |
51 fileName = os.path.basename(argv[1]) |
53 fileName = os.path.basename(argv[1]) |
52 if fileName.startswith("hg-histedit-"): |
54 if fileName.startswith("hg-histedit-"): |
53 from HgHisteditPlanEditor import HgHisteditPlanEditor |
55 from HgHisteditPlanEditor import HgHisteditPlanEditor |
|
56 |
54 return HgHisteditPlanEditor(argv[1]) |
57 return HgHisteditPlanEditor(argv[1]) |
55 elif fileName.startswith("hg-editor-"): |
58 elif fileName.startswith("hg-editor-"): |
56 from HgHisteditCommitEditor import HgHisteditCommitEditor |
59 from HgHisteditCommitEditor import HgHisteditCommitEditor |
|
60 |
57 return HgHisteditCommitEditor(argv[1]) |
61 return HgHisteditCommitEditor(argv[1]) |
58 |
62 |
59 return None |
63 return None |
60 |
64 |
61 |
65 |
62 def main(): |
66 def main(): |
63 """ |
67 """ |
64 Main entry point into the application. |
68 Main entry point into the application. |
65 """ |
69 """ |
66 options = [ |
70 options = [ |
67 ("--config=configDir", |
71 ( |
68 "use the given directory as the one containing the config files"), |
72 "--config=configDir", |
69 ("--settings=settingsDir", |
73 "use the given directory as the one containing the config files", |
70 "use the given directory to store the settings files"), |
74 ), |
71 ("", "name of file to edit") |
75 ( |
|
76 "--settings=settingsDir", |
|
77 "use the given directory to store the settings files", |
|
78 ), |
|
79 ("", "name of file to edit"), |
72 ] |
80 ] |
73 appinfo = AppInfo.makeAppInfo(sys.argv, |
81 appinfo = AppInfo.makeAppInfo( |
74 "Mercurial Histedit Editor", |
82 sys.argv, |
75 "", |
83 "Mercurial Histedit Editor", |
76 "Editor for the Mercurial histedit command", |
84 "", |
77 options) |
85 "Editor for the Mercurial histedit command", |
78 res = Startup.simpleAppStartup(sys.argv, |
86 options, |
79 appinfo, |
87 ) |
80 createMainWidget) |
88 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget) |
81 sys.exit(res) |
89 sys.exit(res) |
82 |
90 |
83 if __name__ == '__main__': |
91 |
|
92 if __name__ == "__main__": |
84 main() |
93 main() |