eric7/Plugins/WizardPlugins/EricPluginWizard/Templates.py

branch
eric7
changeset 8312
800c432b34c8
parent 7923
91e843545d9a
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the various plug-in templates.
8 """
9
10 mainTemplate = '''# -*- coding: utf-8 -*-
11
12 # Copyright (c) {year} {author} <{email}>
13 #
14
15 """
16 Module documentation goes here.
17 """
18
19 from PyQt5.QtCore import QObject
20
21 {config0}\
22 # Start-Of-Header
23 name = "{name}"
24 author = "{author} <{email}>"
25 autoactivate = {autoactivate}
26 deactivateable = {deactivateable}
27 version = "{version}"
28 {onDemand}\
29 className = "{className}"
30 packageName = "{packageName}"
31 shortDescription = "{shortDescription}"
32 longDescription = (
33 """{longDescription}"""
34 )
35 needsRestart = {needsRestart}
36 pyqtApi = 2
37 # End-Of-Header
38
39 error = ""
40
41
42 {modulesetup}\
43 {exeData}\
44 {apiFiles}\
45 {preview}\
46 {config1}\
47 class {className}(QObject):
48 """
49 Class documentation goes here.
50 """
51 {config2}\
52 def __init__(self, ui):
53 """
54 Constructor
55
56 @param ui reference to the user interface object
57 @type UI.UserInterface
58 """
59 super({className}, self).__init__(ui)
60 self.__ui = ui
61
62 def activate(self):
63 """
64 Public method to activate this plug-in.
65
66 @return tuple of None and activation status
67 @rtype bool
68 """
69 global error
70 error = "" # clear previous error
71
72 return None, True
73
74 def deactivate(self):
75 """
76 Public method to deactivate this plug-in.
77 """
78 pass
79 {config3}'''
80
81 configTemplate0 = '''import Preferences
82
83 '''
84
85 configTemplate1 = '''def getConfigData():
86 """
87 Module function returning data as required by the configuration dialog.
88
89 @return dictionary containing the relevant data
90 @rtype dict
91 """
92 return {{
93 "<unique key>": ["<display string>", "<pixmap filename>",
94 pageCreationFunction, None, None],
95 }}
96
97
98 def prepareUninstall():
99 """
100 Module function to prepare for an un-installation.
101 """
102 Preferences.Prefs.settings.remove({className}.PreferencesKey)
103
104
105 '''
106
107 configTemplate2 = ''' PreferencesKey = "{preferencesKey}"
108
109 '''
110
111 configTemplate3 = '''\
112
113 def getPreferences(self, key):
114 """
115 Public method to retrieve the various settings values.
116
117 @param key the key of the value to get
118 @type str
119 @return the requested setting value
120 @rtype any
121 """
122 return None
123
124 def setPreferences(self, key, value):
125 """
126 Public method to store the various settings values.
127
128 @param key the key of the setting to be set
129 @type str
130 @param value the value to be set
131 @type any
132 """
133 pass
134 '''
135
136 onDemandTemplate = '''pluginType = "{pluginType}"
137 pluginTypename = "{pluginTypename}"
138 '''
139
140 previewPixmapTemplate = '''def previewPix():
141 """
142 Module function to return a preview pixmap.
143
144 @return preview pixmap
145 @rtype QPixmap
146 """
147 from PyQt5.QtGui import QPixmap
148
149 fname = "preview.png"
150 return QPixmap(fname)
151
152
153 '''
154
155 exeDisplayDataListTemplate = '''def exeDisplayDataList():
156 """
157 Module function to support the display of some executable info.
158
159 @return list of dictionaries containing the data to query the presence of
160 the executable
161 @rtype list of dict
162 """
163 dataList = []
164 data = {
165 "programEntry": True,
166 "header": "<translated header string>",
167 "exe": "dummyExe",
168 "versionCommand": "--version",
169 "versionStartsWith": "dummyExe",
170 "versionRe": "",
171 "versionPosition": -1,
172 "version": "",
173 "versionCleanup": None,
174 "exeModule": None,
175 }
176 for exePath in ["exe1", "exe2"]:
177 data["exe"] = exePath
178 data["versionStartsWith"] = "<identifier>"
179 dataList.append(data.copy())
180 return dataList
181
182
183 '''
184
185 exeDisplayDataTemplate = '''def exeDisplayData():
186 """
187 Module function to support the display of some executable info.
188
189 @return dictionary containing the data to query the presence of
190 the executable
191 @rtype dict
192 """
193 data = {
194 "programEntry": True,
195 "header": "<translated header string>",
196 "exe": exe,
197 "versionCommand": "--version",
198 "versionStartsWith": "<identifier>",
199 "versionRe": "",
200 "versionPosition": -1,
201 "version": "",
202 "versionCleanup": None,
203 "exeModule": None,
204 }
205
206 return data
207
208
209 '''
210
211 exeDisplayDataInfoTemplate = '''def exeDisplayData():
212 """
213 Module function to support the display of some executable info.
214
215 @return dictionary containing the data to be shown
216 @rtype dict
217 """
218 data = {
219 "programEntry": False,
220 "header": "<translated header string>",
221 "text": "<translated entry string>",
222 "version": "",
223 }
224
225 return data
226
227
228 '''
229
230 moduleSetupTemplate = '''def moduleSetup():
231 """
232 Module function to perform module level setup.
233 """
234 pass
235
236
237 '''
238
239 apiFilesTemplate = '''def apiFiles(language):
240 """
241 Module function to return the API files made available by this plug-in.
242
243 @param language language to get APIs for
244 @type str
245 @return list of API filenames
246 @rtype list of str
247 """
248 if language in ["Python3", "Python"]:
249 apisDir = os.path.join(
250 os.path.dirname(__file__), "APIs", "Python")
251 apis = glob.glob(os.path.join(apisDir, '*.api'))
252 apisDir = os.path.join(
253 os.path.dirname(__file__), "APIs", "Python3")
254 apis.extend(glob.glob(os.path.join(apisDir, '*.api')))
255 else:
256 apis = []
257 return apis
258
259
260 '''
261
262 #
263 # eflag: noqa = M841

eric ide

mercurial