eric6/Plugins/WizardPlugins/EricPluginWizard/Templates.py

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

eric ide

mercurial