src/eric7/eric7_pluginrepository.py

branch
eric7
changeset 10303
ee1aadab1215
parent 10238
9ea4634a697e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10302:8cb0dabf852f 10303:ee1aadab1215
9 9
10 This is the main Python script to install eric plugins from outside of the 10 This is the main Python script to install eric plugins from outside of the
11 IDE. 11 IDE.
12 """ 12 """
13 13
14 import argparse
14 import os 15 import os
15 import sys 16 import sys
16 17
17 from PyQt6.QtGui import QGuiApplication 18 from PyQt6.QtGui import QGuiApplication
18 19
19 for arg in sys.argv[:]:
20 if arg.startswith("--config="):
21 from eric7 import Globals
22 20
23 configDir = arg.replace("--config=", "") 21 def createArgparseNamespace():
24 Globals.setConfigDir(configDir) 22 """
25 sys.argv.remove(arg) 23 Function to create an argument parser.
26 elif arg.startswith("--settings="):
27 from PyQt6.QtCore import QSettings
28 24
29 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) 25 @return created argument parser object
30 if not os.path.isdir(settingsDir): 26 @rtype argparse.ArgumentParser
31 os.makedirs(settingsDir) 27 """
32 QSettings.setPath( 28 from eric7.UI.Info import Version
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir
34 )
35 sys.argv.remove(arg)
36 29
37 from eric7.Globals import AppInfo 30 # 1. create the argument parser
31 parser = argparse.ArgumentParser(
32 description="Graphical tool of the eric tool suite to show the contents of the"
33 " eric Plugins repository.",
34 epilog="Copyright (c) 2007 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>.",
35 )
36
37 # 2. add the arguments
38 parser.add_argument(
39 "-V",
40 "--version",
41 action="version",
42 version="%(prog)s {0}".format(Version),
43 help="show version information and exit",
44 )
45 parser.add_argument(
46 "--config",
47 metavar="config_dir",
48 help="use the given directory as the one containing the config files",
49 )
50 parser.add_argument(
51 "--settings",
52 metavar="settings_dir",
53 help="use the given directory to store the settings files",
54 )
55
56 # 3. create the Namespace object by parsing the command line
57 args = parser.parse_args()
58 return args
59
60
61 args = createArgparseNamespace()
62 if args.config:
63 from eric7 import Globals
64
65 Globals.setConfigDir(args.config)
66 if args.settings:
67 from PyQt6.QtCore import QSettings
68
69 SettingsDir = os.path.expanduser(args.settings)
70 if not os.path.isdir(SettingsDir):
71 os.makedirs(SettingsDir)
72 QSettings.setPath(
73 QSettings.Format.IniFormat, QSettings.Scope.UserScope, SettingsDir
74 )
75
38 from eric7.Toolbox import Startup 76 from eric7.Toolbox import Startup
39 77
40 78
41 def createMainWidget(argv): # noqa: U100 79 def createMainWidget(args): # noqa: U100
42 """ 80 """
43 Function to create the main widget. 81 Function to create the main widget.
44 82
45 @param argv list of commandline parameters (list of strings) 83 @param args namespace object containing the parsed command line parameters
46 @return reference to the main widget (QWidget) 84 @type argparse.Namespace
85 @return reference to the main widget
86 @rtype QWidget
47 """ 87 """
48 from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryWindow 88 from eric7.PluginManager.PluginRepositoryDialog import PluginRepositoryWindow
49 89
50 return PluginRepositoryWindow(None) 90 return PluginRepositoryWindow(None)
51 91
54 """ 94 """
55 Main entry point into the application. 95 Main entry point into the application.
56 """ 96 """
57 QGuiApplication.setDesktopFileName("eric7_pluginrepository") 97 QGuiApplication.setDesktopFileName("eric7_pluginrepository")
58 98
59 options = [ 99 res = Startup.appStartup(args, createMainWidget)
60 (
61 "--config=configDir",
62 "use the given directory as the one containing the config files",
63 ),
64 (
65 "--settings=settingsDir",
66 "use the given directory to store the settings files",
67 ),
68 ]
69 appinfo = AppInfo.makeAppInfo(
70 sys.argv,
71 "eric Plugin Repository",
72 "",
73 "Utility to show the contents of the eric Plugin repository.",
74 options,
75 )
76 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget)
77 sys.exit(res) 100 sys.exit(res)
78 101
79 102
80 if __name__ == "__main__": 103 if __name__ == "__main__":
81 main() 104 main()

eric ide

mercurial