Utilities/Startup.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1509
c0b5e693b0eb
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
22 import UI.PixmapCache 22 import UI.PixmapCache
23 23
24 from eric5config import getConfig 24 from eric5config import getConfig
25 25
26 26
27 def makeAppInfo(argv, name, arg, description, options = []): 27 def makeAppInfo(argv, name, arg, description, options=[]):
28 """ 28 """
29 Module function to generate a dictionary describing the application. 29 Module function to generate a dictionary describing the application.
30 30
31 @param argv list of commandline parameters (list of strings) 31 @param argv list of commandline parameters (list of strings)
32 @param name name of the application (string) 32 @param name name of the application (string)
42 "bin": argv[0], 42 "bin": argv[0],
43 "arg": arg, 43 "arg": arg,
44 "name": name, 44 "name": name,
45 "description": description, 45 "description": description,
46 "version": Version, 46 "version": Version,
47 "options" : options 47 "options": options
48 } 48 }
49 49
50 def usage(appinfo, optlen = 12): 50
51 def usage(appinfo, optlen=12):
51 """ 52 """
52 Module function to show the usage information. 53 Module function to show the usage information.
53 54
54 @param appinfo dictionary describing the application 55 @param appinfo dictionary describing the application
55 @param optlen length of the field for the commandline option (integer) 56 @param optlen length of the field for the commandline option (integer)
68 Options:""".format(**appinfo)) 69 Options:""".format(**appinfo))
69 for opt in options: 70 for opt in options:
70 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1])) 71 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1]))
71 sys.exit(0) 72 sys.exit(0)
72 73
74
73 def version(appinfo): 75 def version(appinfo):
74 """ 76 """
75 Module function to show the version information. 77 Module function to show the version information.
76 78
77 @param appinfo dictionary describing the application 79 @param appinfo dictionary describing the application
84 Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> 86 Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de>
85 This is free software; see LICENSE.GPL3 for copying conditions. 87 This is free software; see LICENSE.GPL3 for copying conditions.
86 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 88 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
87 PARTICULAR PURPOSE.""".format(**appinfo)) 89 PARTICULAR PURPOSE.""".format(**appinfo))
88 sys.exit(0) 90 sys.exit(0)
91
89 92
90 def handleArgs(argv, appinfo): 93 def handleArgs(argv, appinfo):
91 """ 94 """
92 Module function to handle the always present commandline options. 95 Module function to handle the always present commandline options.
93 96
108 for a in args: 111 for a in args:
109 if a in argv and argv.index(a) < ddindex: 112 if a in argv and argv.index(a) < ddindex:
110 args[a](appinfo) 113 args[a](appinfo)
111 return ddindex 114 return ddindex
112 115
116
113 def loadTranslatorForLocale(dirs, tn): 117 def loadTranslatorForLocale(dirs, tn):
114 """ 118 """
115 Module function to find and load a specific translation. 119 Module function to find and load a specific translation.
116 120
117 @param dirs Searchpath for the translations. (list of strings) 121 @param dirs Searchpath for the translations. (list of strings)
125 return (trans, True) 129 return (trans, True)
126 130
127 print("Warning: translation file '" + tn + "'could not be loaded.") 131 print("Warning: translation file '" + tn + "'could not be loaded.")
128 print("Using default.") 132 print("Using default.")
129 return (None, False) 133 return (None, False)
134
130 135
131 def initializeResourceSearchPath(): 136 def initializeResourceSearchPath():
132 """ 137 """
133 Module function to initialize the default mime source factory. 138 Module function to initialize the default mime source factory.
134 """ 139 """
137 for iconPath in iconPaths: 142 for iconPath in iconPaths:
138 if iconPath: 143 if iconPath:
139 UI.PixmapCache.addSearchPath(iconPath) 144 UI.PixmapCache.addSearchPath(iconPath)
140 if not defaultIconPath in iconPaths: 145 if not defaultIconPath in iconPaths:
141 UI.PixmapCache.addSearchPath(defaultIconPath) 146 UI.PixmapCache.addSearchPath(defaultIconPath)
147
142 148
143 def setLibraryPaths(): 149 def setLibraryPaths():
144 """ 150 """
145 Module function to set the Qt library paths correctly for windows systems. 151 Module function to set the Qt library paths correctly for windows systems.
146 """ 152 """
155 QApplication.setLibraryPaths(libraryPaths) 161 QApplication.setLibraryPaths(libraryPaths)
156 162
157 # the translator must not be deleted, therefore we save them here 163 # the translator must not be deleted, therefore we save them here
158 loaded_translators = {} 164 loaded_translators = {}
159 165
160 def loadTranslators(qtTransDir, app, translationFiles = ()): 166
167 def loadTranslators(qtTransDir, app, translationFiles=()):
161 """ 168 """
162 Module function to load all required translations. 169 Module function to load all required translations.
163 170
164 @param qtTransDir directory of the Qt translations files (string) 171 @param qtTransDir directory of the Qt translations files (string)
165 @param app reference to the application object (QApplication) 172 @param app reference to the application object (QApplication)
192 loc = loca 199 loc = loca
193 else: 200 else:
194 loc = None 201 loc = None
195 return loc 202 return loc
196 203
197 def simpleAppStartup(argv, appinfo, mwFactory, quitOnLastWindowClosed = True, 204
198 app = None): 205 def simpleAppStartup(argv, appinfo, mwFactory, quitOnLastWindowClosed=True,
206 app=None):
199 """ 207 """
200 Module function to start up an application that doesn't need a specialized start up. 208 Module function to start up an application that doesn't need a specialized start up.
201 209
202 This function is used by all of eric5's helper programs. 210 This function is used by all of eric5's helper programs.
203 211

eric ide

mercurial