🔥 Remove deprecated plugin control properties

__plugin_init__ and __plugin_implementations__ (plural!) have been
deprecated since 1.2.0.dev, time to nuke them.
This commit is contained in:
Gina Häußge committed 2020-11-11 12:04:30 +01:00
1 parent 8fce191c55
commit cca3000eb2
1 file changed
+2 -69
+2 -69
View File
@@ -207,35 +207,12 @@ class PluginInfo(object):
attr_implementation = "__plugin_implementation__"
""" Module attribute from which to retrieve the plugin's provided mixin implementation. """
attr_implementations = "__plugin_implementations__"
"""
Module attribute from which to retrieve the plugin's provided implementations.
This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_implementation`. Only the
first entry will be evaluated.
.. deprecated:: 1.2.0-dev-694
Use :attr:`attr_implementation` instead.
"""
attr_helpers = "__plugin_helpers__"
""" Module attribute from which to retrieve the plugin's provided helpers. """
attr_check = "__plugin_check__"
""" Module attribute which to call to determine if the plugin can be loaded. """
attr_init = "__plugin_init__"
"""
Module attribute which to call when loading the plugin.
This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_load`.
.. deprecated:: 1.2.0-dev-720
Use :attr:`attr_load` instead.
"""
attr_load = "__plugin_load__"
""" Module attribute which to call when loading the plugin. """
@@ -331,54 +308,10 @@ class PluginInfo(object):
)
elif phase == "before_load":
# if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__
if hasattr(self.instance, self.__class__.attr_init):
if not hasattr(self.instance, self.__class__.attr_load):
# deprecation warning
import warnings
warnings.warn(
"{name} uses deprecated control property __plugin_init__, use __plugin_load__ instead".format(
name=self.key
),
DeprecationWarning,
)
# move it
init = getattr(self.instance, self.__class__.attr_init)
setattr(self.instance, self.__class__.attr_load, init)
# delete __plugin_init__
delattr(self.instance, self.__class__.attr_init)
pass
elif phase == "after_load":
# if the plugin still uses __plugin_implementations__, log a deprecation warning and put the first
# item into __plugin_implementation__
if hasattr(self.instance, self.__class__.attr_implementations):
if not hasattr(self.instance, self.__class__.attr_implementation):
# deprecation warning
import warnings
warnings.warn(
"{name} uses deprecated control property __plugin_implementations__, use __plugin_implementation__ instead - only the first implementation of {name} will be recognized".format(
name=self.key
),
DeprecationWarning,
)
# put first item into __plugin_implementation__
implementations = getattr(
self.instance, self.__class__.attr_implementations
)
if len(implementations) > 0:
setattr(
self.instance,
self.__class__.attr_implementation,
implementations[0],
)
# delete __plugin_implementations__
delattr(self.instance, self.__class__.attr_implementations)
pass
if additional_validators is not None:
for validator in additional_validators: