eric7/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditEditor.py

branch
eric7
changeset 8312
800c432b34c8
parent 8143
2c730d5fd177
child 8314
e3642a6a1e71
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Module implementing the main script for histedit.
9
10 Depending on the file name given by the Mercurial histedit command one
11 of two possible dialogs will be shown.
12 """
13
14 import sys
15 import os
16
17 sys.path.insert(1, os.path.join(
18 os.path.dirname(__file__), "..", "..", "..", ".."))
19 # four times up is the eric6 package directory
20
21 for arg in sys.argv[:]:
22 if arg.startswith("--config="):
23 import Globals
24 configDir = arg.replace("--config=", "")
25 Globals.setConfigDir(configDir)
26 sys.argv.remove(arg)
27 elif arg.startswith("--settings="):
28 from PyQt5.QtCore import QSettings
29 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
30 if not os.path.isdir(settingsDir):
31 os.makedirs(settingsDir)
32 QSettings.setPath(
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir)
34 sys.argv.remove(arg)
35
36 from Globals import AppInfo
37
38 from Toolbox import Startup
39
40
41 def createMainWidget(argv):
42 """
43 Function to create the main widget.
44
45 @param argv list of commandline parameters
46 @type list of str
47 @return reference to the main widget or None in case of an error
48 @rtype QWidget or None
49 """
50 if len(argv) > 1:
51 fileName = os.path.basename(argv[1])
52 if fileName.startswith("hg-histedit-"):
53 from HgHisteditPlanEditor import HgHisteditPlanEditor
54 return HgHisteditPlanEditor(argv[1])
55 elif fileName.startswith("hg-editor-"):
56 from HgHisteditCommitEditor import HgHisteditCommitEditor
57 return HgHisteditCommitEditor(argv[1])
58
59 return None
60
61
62 def main():
63 """
64 Main entry point into the application.
65 """
66 options = [
67 ("--config=configDir",
68 "use the given directory as the one containing the config files"),
69 ("--settings=settingsDir",
70 "use the given directory to store the settings files"),
71 ("", "name of file to edit")
72 ]
73 appinfo = AppInfo.makeAppInfo(sys.argv,
74 "Mercurial Histedit Editor",
75 "",
76 "Editor for the Mercurial histedit command",
77 options)
78 res = Startup.simpleAppStartup(sys.argv,
79 appinfo,
80 createMainWidget)
81 sys.exit(res)
82
83 if __name__ == '__main__':
84 main()

eric ide

mercurial