src/eric7/eric7_compare.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 sys.path.insert(1, os.path.dirname(__file__)) 18 sys.path.insert(1, os.path.dirname(__file__))
19 19
20 for arg in sys.argv[:]: 20 for arg in sys.argv[:]:
21 if arg.startswith("--config="): 21 if arg.startswith("--config="):
22 import Globals 22 import Globals
23
23 configDir = arg.replace("--config=", "") 24 configDir = arg.replace("--config=", "")
24 Globals.setConfigDir(configDir) 25 Globals.setConfigDir(configDir)
25 sys.argv.remove(arg) 26 sys.argv.remove(arg)
26 elif arg.startswith("--settings="): 27 elif arg.startswith("--settings="):
27 from PyQt6.QtCore import QSettings 28 from PyQt6.QtCore import QSettings
29
28 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) 30 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
29 if not os.path.isdir(settingsDir): 31 if not os.path.isdir(settingsDir):
30 os.makedirs(settingsDir) 32 os.makedirs(settingsDir)
31 QSettings.setPath( 33 QSettings.setPath(
32 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) 34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir
35 )
33 sys.argv.remove(arg) 36 sys.argv.remove(arg)
34 37
35 from Globals import AppInfo 38 from Globals import AppInfo
36 39
37 from Toolbox import Startup 40 from Toolbox import Startup
38 41
39 42
40 def createMainWidget(argv): 43 def createMainWidget(argv):
41 """ 44 """
42 Function to create the main widget. 45 Function to create the main widget.
43 46
44 @param argv list of commandline parameters (list of strings) 47 @param argv list of commandline parameters (list of strings)
45 @return reference to the main widget (QWidget) 48 @return reference to the main widget (QWidget)
46 """ 49 """
47 from UI.CompareDialog import CompareWindow 50 from UI.CompareDialog import CompareWindow
51
48 if len(argv) >= 6: 52 if len(argv) >= 6:
49 # assume last two entries are the files to compare 53 # assume last two entries are the files to compare
50 file1 = (argv[-4], argv[-2]) 54 file1 = (argv[-4], argv[-2])
51 file2 = (argv[-3], argv[-1]) 55 file2 = (argv[-3], argv[-1])
52 return CompareWindow([file1, file2]) 56 return CompareWindow([file1, file2])
59 def main(): 63 def main():
60 """ 64 """
61 Main entry point into the application. 65 Main entry point into the application.
62 """ 66 """
63 from PyQt6.QtGui import QGuiApplication 67 from PyQt6.QtGui import QGuiApplication
68
64 QGuiApplication.setDesktopFileName("eric7_compare.desktop") 69 QGuiApplication.setDesktopFileName("eric7_compare.desktop")
65 70
66 options = [ 71 options = [
67 ("--config=configDir", 72 (
68 "use the given directory as the one containing the config files"), 73 "--config=configDir",
69 ("--settings=settingsDir", 74 "use the given directory as the one containing the config files",
70 "use the given directory to store the settings files"), 75 ),
76 (
77 "--settings=settingsDir",
78 "use the given directory to store the settings files",
79 ),
71 ] 80 ]
72 appinfo = AppInfo.makeAppInfo(sys.argv, 81 appinfo = AppInfo.makeAppInfo(
73 "eric Compare", 82 sys.argv, "eric Compare", "", "Simple graphical compare tool", options
74 "", 83 )
75 "Simple graphical compare tool", 84 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget)
76 options)
77 res = Startup.simpleAppStartup(sys.argv,
78 appinfo,
79 createMainWidget)
80 sys.exit(res) 85 sys.exit(res)
81 86
82 if __name__ == '__main__': 87
88 if __name__ == "__main__":
83 main() 89 main()

eric ide

mercurial