| ... |
... |
@@ -164,6 +164,25 @@ class Plugin(): |
|
164
|
164
|
core format version :ref:`core format version <project_format_version>`.
|
|
165
|
165
|
"""
|
|
166
|
166
|
|
|
|
167
|
+ BST_PLUGIN_DEPRECATED = False
|
|
|
168
|
+ """True if this element plugin has been deprecated.
|
|
|
169
|
+
|
|
|
170
|
+ If this is set to true, the plugin will call self.eimit_deprecation_warning()
|
|
|
171
|
+ on instantiation. Plugin authors may override this method to provide
|
|
|
172
|
+ custom deprecation warnings
|
|
|
173
|
+
|
|
|
174
|
+ *Since 1.4*
|
|
|
175
|
+ """
|
|
|
176
|
+
|
|
|
177
|
+ BST_PLUGIN_DEPRECATION_MESSAGE = ""
|
|
|
178
|
+ """ The message printed when this element shows a deprecation warning.
|
|
|
179
|
+
|
|
|
180
|
+ This should be set if BST_PLUGIN_DEPRECATED is True and should direct the user
|
|
|
181
|
+ to the deprecated plug-in's replacement.
|
|
|
182
|
+
|
|
|
183
|
+ *Since 1.4*
|
|
|
184
|
+ """
|
|
|
185
|
+
|
|
167
|
186
|
def __init__(self, name, context, project, provenance, type_tag):
|
|
168
|
187
|
|
|
169
|
188
|
self.name = name
|
| ... |
... |
@@ -188,6 +207,14 @@ class Plugin(): |
|
188
|
207
|
self.__kind = modulename.split('.')[-1]
|
|
189
|
208
|
self.debug("Created: {}".format(self))
|
|
190
|
209
|
|
|
|
210
|
+ # If this plugin has been deprecated, emit a warning.
|
|
|
211
|
+ silenced_warnings = self.__project.supressed_deprecation_warnings
|
|
|
212
|
+ if self.BST_PLUGIN_DEPRECATED and self.__kind not in silenced_warnings:
|
|
|
213
|
+ self.__context.message(
|
|
|
214
|
+ Message(message_type=MessageType.WARN,
|
|
|
215
|
+ detail="Using deprecated plugin {}: {}".format(
|
|
|
216
|
+ self.__kind, BST_PLUGIN_DEPRECATION_MESSAGE)))
|
|
|
217
|
+
|
|
191
|
218
|
def __del__(self):
|
|
192
|
219
|
# Dont send anything through the Message() pipeline at destruction time,
|
|
193
|
220
|
# any subsequent lookup of plugin by unique id would raise KeyError.
|