summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-05-31 06:36:55 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commitcd5ecdbaeef153523afdeff77f07945944118115 (patch)
tree9f3d2bd03cd5b918300ae36a4abcee479fa7b52d /ipalib
parent0a984afd8170b349b0745fb89168d363dfa28ffa (diff)
downloadfreeipa-cd5ecdbaeef153523afdeff77f07945944118115.tar.gz
freeipa-cd5ecdbaeef153523afdeff77f07945944118115.tar.xz
freeipa-cd5ecdbaeef153523afdeff77f07945944118115.zip
help, makeapi: specify module topic by name
Specify module topic by name rather than by name and summary. A topic module of the topic name must exist. Summary is extracted from the docstring of the topic module. This changes makes topic handling more generic and consistent between modules and commands. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/cli.py9
-rw-r--r--ipalib/plugins/hbac.py7
-rw-r--r--ipalib/plugins/hbacrule.py2
-rw-r--r--ipalib/plugins/hbacsvc.py2
-rw-r--r--ipalib/plugins/hbacsvcgroup.py2
-rw-r--r--ipalib/plugins/otp.py7
-rw-r--r--ipalib/plugins/otpconfig.py2
-rw-r--r--ipalib/plugins/otptoken.py2
-rw-r--r--ipalib/plugins/sudo.py7
-rw-r--r--ipalib/plugins/sudocmd.py2
-rw-r--r--ipalib/plugins/sudocmdgroup.py2
-rw-r--r--ipalib/plugins/sudorule.py2
12 files changed, 34 insertions, 12 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 5fc5f1fef..5286032fb 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -701,7 +701,7 @@ class help(frontend.Local):
module = importlib.import_module(module_name)
doc = unicode(module.__doc__ or '').strip()
- parent_topic = getattr(module, 'topic', [None])[0]
+ parent_topic = getattr(module, 'topic', None)
return doc, parent_topic
@@ -733,8 +733,7 @@ class help(frontend.Local):
mcl = max((self._topics[topic_name][1], len(c.name)))
self._topics[topic_name][1] = mcl
else: # a module grouped in a topic
- m = '%s.%s' % (self._PLUGIN_BASE_MODULE, c.topic)
- topic = sys.modules[m].topic
+ topic = self._get_topic(topic_name)
mod_name = c.topic
if topic_name in self._topics:
if mod_name in self._topics[topic_name][2]:
@@ -746,7 +745,9 @@ class help(frontend.Local):
mcl = max((self._topics[topic_name][2][mod_name][1], len(c.name)))
self._topics[topic_name][2][mod_name][1] = mcl
else:
- self._topics[topic_name] = [unicode(_(topic[1])), 0, {mod_name: [doc, 0, [c]]}]
+ self._topics[topic_name] = [topic[0].split('\n', 1)[0],
+ 0,
+ {mod_name: [doc, 0, [c]]}]
self._count_topic_mcl(topic_name, mod_name)
else:
self._builtins.append(c)
diff --git a/ipalib/plugins/hbac.py b/ipalib/plugins/hbac.py
new file mode 100644
index 000000000..59defc1f2
--- /dev/null
+++ b/ipalib/plugins/hbac.py
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
+#
+
+from ipalib.text import _
+
+__doc__ = _('Host-based access control commands')
diff --git a/ipalib/plugins/hbacrule.py b/ipalib/plugins/hbacrule.py
index 499e46d04..96015ab65 100644
--- a/ipalib/plugins/hbacrule.py
+++ b/ipalib/plugins/hbacrule.py
@@ -101,7 +101,7 @@ register = Registry()
# ipa hbacrule-add-accesstime --time='absolute 201012161032 ~ 201012161033' test1
-topic = ('hbac', _('Host-based access control commands'))
+topic = 'hbac'
def validate_type(ugettext, type):
if type.lower() == 'deny':
diff --git a/ipalib/plugins/hbacsvc.py b/ipalib/plugins/hbacsvc.py
index f4dc704a0..43d641642 100644
--- a/ipalib/plugins/hbacsvc.py
+++ b/ipalib/plugins/hbacsvc.py
@@ -50,7 +50,7 @@ EXAMPLES:
register = Registry()
-topic = ('hbac', _('Host based access control commands'))
+topic = 'hbac'
@register()
class hbacsvc(LDAPObject):
diff --git a/ipalib/plugins/hbacsvcgroup.py b/ipalib/plugins/hbacsvcgroup.py
index 32c79bbf0..41157efc6 100644
--- a/ipalib/plugins/hbacsvcgroup.py
+++ b/ipalib/plugins/hbacsvcgroup.py
@@ -53,7 +53,7 @@ EXAMPLES:
register = Registry()
-topic = ('hbac', _('Host based access control commands'))
+topic = 'hbac'
@register()
class hbacsvcgroup(LDAPObject):
diff --git a/ipalib/plugins/otp.py b/ipalib/plugins/otp.py
new file mode 100644
index 000000000..306c87388
--- /dev/null
+++ b/ipalib/plugins/otp.py
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
+#
+
+from ipalib.text import _
+
+__doc__ = _('One time password commands')
diff --git a/ipalib/plugins/otpconfig.py b/ipalib/plugins/otpconfig.py
index f1b45dda0..c7710468f 100644
--- a/ipalib/plugins/otpconfig.py
+++ b/ipalib/plugins/otpconfig.py
@@ -49,7 +49,7 @@ EXAMPLES:
register = Registry()
-topic = ('otp', _('One time password commands'))
+topic = 'otp'
@register()
diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py
index 57cb05337..2bd3d3af5 100644
--- a/ipalib/plugins/otptoken.py
+++ b/ipalib/plugins/otptoken.py
@@ -72,7 +72,7 @@ EXAMPLES:
register = Registry()
-topic = ('otp', _('One time password commands'))
+topic = 'otp'
TOKEN_TYPES = {
u'totp': ['ipatokentotpclockoffset', 'ipatokentotptimestep'],
diff --git a/ipalib/plugins/sudo.py b/ipalib/plugins/sudo.py
new file mode 100644
index 000000000..eb1f49ff9
--- /dev/null
+++ b/ipalib/plugins/sudo.py
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
+#
+
+from ipalib.text import _
+
+__doc__ = _('commands for controlling sudo configuration')
diff --git a/ipalib/plugins/sudocmd.py b/ipalib/plugins/sudocmd.py
index 4339c3c86..e3ae33a84 100644
--- a/ipalib/plugins/sudocmd.py
+++ b/ipalib/plugins/sudocmd.py
@@ -47,7 +47,7 @@ EXAMPLES:
register = Registry()
-topic = ('sudo', _('commands for controlling sudo configuration'))
+topic = 'sudo'
@register()
class sudocmd(LDAPObject):
diff --git a/ipalib/plugins/sudocmdgroup.py b/ipalib/plugins/sudocmdgroup.py
index 757d417b9..9e8c016fd 100644
--- a/ipalib/plugins/sudocmdgroup.py
+++ b/ipalib/plugins/sudocmdgroup.py
@@ -56,7 +56,7 @@ EXAMPLES:
register = Registry()
-topic = ('sudo', _('commands for controlling sudo configuration'))
+topic = 'sudo'
@register()
class sudocmdgroup(LDAPObject):
diff --git a/ipalib/plugins/sudorule.py b/ipalib/plugins/sudorule.py
index 62a727b27..b281c5f92 100644
--- a/ipalib/plugins/sudorule.py
+++ b/ipalib/plugins/sudorule.py
@@ -92,7 +92,7 @@ EXAMPLES:
register = Registry()
-topic = ('sudo', _('Commands for controlling sudo configuration'))
+topic = 'sudo'
def deprecated(attribute):