On 07/18/2016 08:46 AM, Jan Cholasta wrote:

On 11.7.2016 14:18, Martin Babinsky wrote:

Note that you should use .name rather than .__name__ to get plugin
names, otherwise the code won't work with plugins with non-default names.

There currently aren't any Advice plugins with non-default name, but I
would rather fix this now to avoid surprises later.


I didn't realize this when doing the patch, here's the fix for that.

I have attached the original closed ticket to the commit message, should I create a new ticket for such a small change?

Martin^3 Babinsky
From 5da15a1a56174d06120c8296d8878e71ec8a66a4 Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Mon, 18 Jul 2016 10:44:23 +0200
Subject: [PATCH] advise: Use `name` instead of `__name__` to get plugin names

This change will allow ipa-advise to correctly handle advise plugins with
custom names.

 ipaserver/advise/base.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py
index a2dc9ccee93811da415c1e1eb0b57f47ac817a3f..f7e8ef5e49c7efc18d5c29583183e908e1284eae 100644
--- a/ipaserver/advise/base.py
+++ b/ipaserver/advise/base.py
@@ -168,11 +168,11 @@ class IpaAdvise(admintool.AdminTool):
         self.print_header('List of available advices')
         max_keyword_len = max(
-            (len(advice.__name__) for advice in advise_api.Advice))
+            (len(advice.name) for advice in advise_api.Advice))
         for advice in advise_api.Advice:
             description = getattr(advice, 'description', '')
-            keyword = advice.__name__.replace('_', '-')
+            keyword = advice.name.replace('_', '-')
             # Compute the number of spaces needed for the table to be aligned
             offset = max_keyword_len - len(keyword)

Manage your subscription for the Freeipa-devel mailing list:
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to