Module: check_mk
Branch: master
Commit: 45e79a939593218d9a8f07644c07135696a36fc9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=45e79a93959321…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jan 11 12:08:26 2019 +0100
No need for two different register methods.
Change-Id: Iae7b473482bb16cb45f218c7cdc11eb541e398d4
---
cmk/gui/dashboard.py | 2 +-
cmk/gui/plugins/views/icons/utils.py | 2 +-
cmk/gui/plugins/wato/builtin_modules.py | 2 +-
cmk/gui/plugins/wato/utils/__init__.py | 2 +-
cmk/gui/plugins/wato/utils/main_menu.py | 2 +-
cmk/gui/plugins/watolib/utils.py | 2 +-
cmk/gui/views.py | 2 +-
cmk/gui/watolib.py | 5 ++---
cmk/utils/plugin_registry.py | 8 +-------
tests/unit/cmk/gui/test_gui_config.py | 2 +-
tests/unit/cmk/utils/test_plugin_registry.py | 4 ++--
11 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/cmk/gui/dashboard.py b/cmk/gui/dashboard.py
index 76480bb..08e8a73 100644
--- a/cmk/gui/dashboard.py
+++ b/cmk/gui/dashboard.py
@@ -715,7 +715,7 @@ def dashboard_edit_controls(name, board):
return 'create_view_dashlet.py?name=%s&create=0&back=%s'
% \
(html.urlencode(name),
html.urlencode(html.makeuri([('edit', '1')])))
- dashlet_registry.register_plugin(ExistingView)
+ dashlet_registry.register(ExistingView)
for ty, dashlet_type in sorted(dashlet_registry.items(), key=lambda x:
x[1].sort_index()):
if dashlet_type.is_selectable():
diff --git a/cmk/gui/plugins/views/icons/utils.py b/cmk/gui/plugins/views/icons/utils.py
index 6dbacd9..47134ad 100644
--- a/cmk/gui/plugins/views/icons/utils.py
+++ b/cmk/gui/plugins/views/icons/utils.py
@@ -176,4 +176,4 @@ def _register_custom_user_icons_and_actions(user_icons_and_actions):
"render": lambda self, *args:
(self._icon_spec["icon"], self._icon_spec.get("title"),
self._icon_spec.get("url")),
})
- icon_and_action_registry.register_plugin(icon_class)
+ icon_and_action_registry.register(icon_class)
diff --git a/cmk/gui/plugins/wato/builtin_modules.py
b/cmk/gui/plugins/wato/builtin_modules.py
index 5ed6ce3..8ef7ef4 100644
--- a/cmk/gui/plugins/wato/builtin_modules.py
+++ b/cmk/gui/plugins/wato/builtin_modules.py
@@ -555,4 +555,4 @@ class MainModuleDownloadAgents(MainModule):
# Register the builtin agent download page on the top level of WATO only when the agent
bakery
# does not exist (e.g. when using CRE)
if cmk.is_raw_edition():
- main_module_registry.register_plugin(MainModuleDownloadAgents)
+ main_module_registry.register(MainModuleDownloadAgents)
diff --git a/cmk/gui/plugins/wato/utils/__init__.py
b/cmk/gui/plugins/wato/utils/__init__.py
index 606dc6b..4341cb6 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -733,7 +733,7 @@ def register_check_parameters(subgroup,
checkparams_static_sub_group_class = type("%sStatic" %
subgroup.__name__, (subgroup,), {
"main_group": main_group_static_class,
})
- rulespec_group_registry.register_plugin(checkparams_static_sub_group_class)
+ rulespec_group_registry.register(checkparams_static_sub_group_class)
register_rule(
checkparams_static_sub_group_class,
diff --git a/cmk/gui/plugins/wato/utils/main_menu.py
b/cmk/gui/plugins/wato/utils/main_menu.py
index 2185e84..5a47040 100644
--- a/cmk/gui/plugins/wato/utils/main_menu.py
+++ b/cmk/gui/plugins/wato/utils/main_menu.py
@@ -190,7 +190,7 @@ def register_modules(*args):
"description": wato_module.description,
"sort_index": wato_module.sort_index,
})
- main_module_registry.register_plugin(cls)
+ main_module_registry.register(cls)
def get_modules():
diff --git a/cmk/gui/plugins/watolib/utils.py b/cmk/gui/plugins/watolib/utils.py
index 5a5d893..45314b4 100644
--- a/cmk/gui/plugins/watolib/utils.py
+++ b/cmk/gui/plugins/watolib/utils.py
@@ -286,4 +286,4 @@ def register_configvar(group,
"allow_reset": lambda self: allow_reset,
"in_global_settings": lambda self: in_global_settings,
})
- config_variable_registry.register_plugin(cls)
+ config_variable_registry.register(cls)
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 21e2820..75d6aa7 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -178,7 +178,7 @@ def transform_old_dict_based_icons():
"service_columns": lambda self:
self._icon_spec.get("service_columns", []),
})
- icon_and_action_registry.register_plugin(icon_class)
+ icon_and_action_registry.register(icon_class)
multisite_views = {} # type: Dict
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index 8cfd5ff..f22dd66 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -7705,8 +7705,7 @@ rulespec_group_registry = RulespecGroupRegistry()
# TODO: Kept for compatibility with pre 1.6 plugins
def register_rulegroup(group_name, title, help_text):
- rulespec_group_registry.register_plugin(
- _get_legacy_rulespec_group_class(group_name, title, help_text))
+ rulespec_group_registry.register(_get_legacy_rulespec_group_class(group_name, title,
help_text))
def get_rulegroup(group_name):
@@ -7714,7 +7713,7 @@ def get_rulegroup(group_name):
group_class = rulespec_group_registry[group_name]
except KeyError:
group_class = _get_legacy_rulespec_group_class(group_name, group_title=None,
help_text=None)
- rulespec_group_registry.register_plugin(group_class)
+ rulespec_group_registry.register(group_class)
return group_class()
diff --git a/cmk/utils/plugin_registry.py b/cmk/utils/plugin_registry.py
index a409d32..14844d0 100644
--- a/cmk/utils/plugin_registry.py
+++ b/cmk/utils/plugin_registry.py
@@ -56,19 +56,13 @@ class ClassRegistry(object):
raise NotImplementedError()
def register(self, plugin_class):
- """Decorator to register a class with the
registry"""
+ """Register a class with the registry, can be used as a
decorator"""
if not issubclass(plugin_class, self.plugin_base_class()):
raise TypeError('%s is not a subclass of %s' %
(plugin_class.__name__,
self.plugin_base_class().__name__))
self._register(plugin_class)
return plugin_class
- def register_plugin(self, plugin_class):
- """Method for registering a plugin with the registry.
-
- Result is equal to use the register() decorator"""
- self.register(plugin_class)
-
@abc.abstractmethod
def _register(self, plugin_class):
raise NotImplementedError()
diff --git a/tests/unit/cmk/gui/test_gui_config.py
b/tests/unit/cmk/gui/test_gui_config.py
index 80343ee..c591d5c 100644
--- a/tests/unit/cmk/gui/test_gui_config.py
+++ b/tests/unit/cmk/gui/test_gui_config.py
@@ -555,7 +555,7 @@ def test_permission_sorting(do_sort, result):
"description": "bla",
"defaults": ["admin"],
})
- perms.register_plugin(cls)
+ perms.register(cls)
sorted_perms = [p.name for p in perms.get_sorted_permissions(Sec1())]
assert sorted_perms == result
diff --git a/tests/unit/cmk/utils/test_plugin_registry.py
b/tests/unit/cmk/utils/test_plugin_registry.py
index 049510f..562077b 100644
--- a/tests/unit/cmk/utils/test_plugin_registry.py
+++ b/tests/unit/cmk/utils/test_plugin_registry.py
@@ -18,7 +18,7 @@ class PluginRegistry(cmk.utils.plugin_registry.ClassRegistry):
@pytest.fixture(scope="module")
def basic_registry():
registry = PluginRegistry()
- registry.register_plugin(Plugin)
+ registry.register(Plugin)
return registry
@@ -45,7 +45,7 @@ def test_method_registration():
class MethodRegisteredPlugin(Plugin):
pass
- registry.register_plugin(MethodRegisteredPlugin)
+ registry.register(MethodRegisteredPlugin)
assert registry.get("MethodRegisteredPlugin") == MethodRegisteredPlugin