|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2017 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 {exeDataList}\ |
|
50 {apiFiles}\ |
|
51 {preview}\ |
|
52 {config1}\ |
|
53 class {className}(QObject): |
|
54 """ |
|
55 Class documentation goes here. |
|
56 """ |
|
57 {config2}\ |
|
58 def __init__(self, ui): |
|
59 """ |
|
60 Constructor |
|
61 |
|
62 @param ui reference to the user interface object (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 plugin. |
|
70 |
|
71 @return tuple of None and activation status (boolean) |
|
72 """ |
|
73 global error |
|
74 error = "" # clear previous error |
|
75 |
|
76 return None, True |
|
77 |
|
78 def deactivate(self): |
|
79 """ |
|
80 Public method to deactivate this plugin. |
|
81 """ |
|
82 pass |
|
83 {config3}''' |
|
84 |
|
85 configTemplate0 = '''import Preferences |
|
86 |
|
87 ''' |
|
88 |
|
89 configTemplate1 = '''def getConfigData(): |
|
90 """ |
|
91 Module function returning data as required by the configuration dialog. |
|
92 |
|
93 @return dictionary containing the relevant data |
|
94 """ |
|
95 return {{ |
|
96 "<unique key>": ["<display string>", "<pixmap filename>", |
|
97 pageCreationFunction, None, None], |
|
98 }} |
|
99 |
|
100 |
|
101 def prepareUninstall(): |
|
102 """ |
|
103 Module function to prepare for an uninstallation. |
|
104 """ |
|
105 Preferences.Prefs.settings.remove({className}.PreferencesKey) |
|
106 |
|
107 |
|
108 ''' |
|
109 |
|
110 configTemplate2 = ''' PreferencesKey = "{preferencesKey}" |
|
111 |
|
112 ''' |
|
113 |
|
114 configTemplate3 = '''\ |
|
115 |
|
116 def getPreferences(self, key): |
|
117 """ |
|
118 Public method to retrieve the various refactoring settings. |
|
119 |
|
120 @param key the key of the value to get |
|
121 @return the requested refactoring setting |
|
122 """ |
|
123 return None |
|
124 |
|
125 def setPreferences(self, key, value): |
|
126 """ |
|
127 Public method to store the various refactoring settings. |
|
128 |
|
129 @param key the key of the setting to be set (string) |
|
130 @param value the value to be set |
|
131 """ |
|
132 pass |
|
133 ''' |
|
134 |
|
135 onDemandTemplate = '''pluginType = "{pluginType}" |
|
136 pluginTypename = "{pluginTypename}" |
|
137 ''' |
|
138 |
|
139 previewPixmapTemplate = '''def previewPix(): |
|
140 """ |
|
141 Module function to return a preview pixmap. |
|
142 |
|
143 @return preview pixmap (QPixmap) |
|
144 """ |
|
145 from PyQt5.QtGui import QPixmap |
|
146 |
|
147 fname = "preview.png" |
|
148 return QPixmap(fname) |
|
149 |
|
150 |
|
151 ''' |
|
152 |
|
153 exeDisplayDataListTemplate = '''def exeDisplayDataList(): |
|
154 """ |
|
155 Module function to support the display of some executable info. |
|
156 |
|
157 @return list of dictionaries containing the data to query the presence of |
|
158 the executable |
|
159 """ |
|
160 dataList = [] |
|
161 data = { |
|
162 "programEntry": True, |
|
163 "header": "<translated header string>", |
|
164 "exe": "dummyExe", |
|
165 "versionCommand": "--version", |
|
166 "versionStartsWith": "dummyExe", |
|
167 "versionPosition": -1, |
|
168 "version": "", |
|
169 "versionCleanup": None, |
|
170 } |
|
171 for exePath in ["exe1", "exe2"]: |
|
172 data["exe"] = exePath |
|
173 data["versionStartsWith"] = "<identifier>" |
|
174 dataList.append(data.copy()) |
|
175 return dataList |
|
176 |
|
177 |
|
178 ''' |
|
179 |
|
180 exeDisplayDataTemplate = '''def exeDisplayData(): |
|
181 """ |
|
182 Module function to support the display of some executable info. |
|
183 |
|
184 @return dictionary containing the data to query the presence of |
|
185 the executable |
|
186 """ |
|
187 data = { |
|
188 "programEntry": True, |
|
189 "header": "<translated header string>", |
|
190 "exe": exe, |
|
191 "versionCommand": "--version", |
|
192 "versionStartsWith": "<identifier>", |
|
193 "versionPosition": -1, |
|
194 "version": "", |
|
195 "versionCleanup": None, |
|
196 } |
|
197 |
|
198 return data |
|
199 |
|
200 |
|
201 ''' |
|
202 |
|
203 moduleSetupTemplate = '''def moduleSetup(): |
|
204 """ |
|
205 Module function to perform module level setup. |
|
206 """ |
|
207 pass |
|
208 |
|
209 |
|
210 ''' |
|
211 |
|
212 apiFilesTemplate = '''def apiFiles(language): |
|
213 """ |
|
214 Module function to return the API files made available by this plugin. |
|
215 |
|
216 @param language language to get APIs for (string) |
|
217 @return list of API filenames (list of string) |
|
218 """ |
|
219 if language in ["Python3", "Python2", "Python"]: |
|
220 apisDir = \\ |
|
221 os.path.join(os.path.dirname(__file__), "APIs", "Python") |
|
222 apis = glob.glob(os.path.join(apisDir, '*.api')) |
|
223 if language == "Python3": |
|
224 apisDir = \\ |
|
225 os.path.join(os.path.dirname(__file__), "APIs", "Python3") |
|
226 apis.extend(glob.glob(os.path.join(apisDir, '*.api'))) |
|
227 else: |
|
228 apisDir = \\ |
|
229 os.path.join(os.path.dirname(__file__), "APIs", "Python2") |
|
230 apis.extend(glob.glob(os.path.join(apisDir, '*.api'))) |
|
231 else: |
|
232 apis = [] |
|
233 return apis |
|
234 |
|
235 |
|
236 ''' |