summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorDavid Kupka <dkupka@redhat.com>2016-07-20 13:24:03 +0200
committerJan Cholasta <jcholast@redhat.com>2016-08-03 16:32:39 +0200
commite76b0bbbcc77aa0473f209beeb538c8313172c66 (patch)
treed69d0af4c4ec0a5e1d95306468c3526e726032d8 /ipalib/cli.py
parent23609d59559f15d4414ce87b850b6e845ed1cd40 (diff)
downloadfreeipa-e76b0bbbcc77aa0473f209beeb538c8313172c66.tar.gz
freeipa-e76b0bbbcc77aa0473f209beeb538c8313172c66.tar.xz
freeipa-e76b0bbbcc77aa0473f209beeb538c8313172c66.zip
help: Do not create instances to get information about commands and topics
Creating instance requires that complete schema for the command is read from schema cache and passed to constructor. This operation takes a lot of time. Utilizing class properties and pregenerated help bits allows to get the necessary information directly from classes reducing time it takes significantly. https://fedorahosted.org/freeipa/ticket/6048 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 1faf8285c..d89a53208 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -727,8 +727,8 @@ class help(frontend.Local):
self._builtins = []
# build help topics
- for c in self.api.Command():
- if c is not self.api.Command[c.name]:
+ for c in self.api.Command:
+ if c is not self.api.Command.get_plugin(c.name):
continue
if c.NO_CLI:
continue
@@ -793,13 +793,14 @@ class help(frontend.Local):
self.print_commands(name, outfile)
elif name == "commands":
mcl = 0
- for cmd in self.Command():
- if cmd is not self.Command[cmd.name]:
+ for cmd_plugin in self.Command:
+ if cmd_plugin is not self.Command.get_plugin(cmd_plugin.name):
continue
- if cmd.NO_CLI:
+ if cmd_plugin.NO_CLI:
continue
- mcl = max(mcl, len(cmd.name))
- writer('%s %s' % (to_cli(cmd.name).ljust(mcl), cmd.summary))
+ mcl = max(mcl, len(cmd_plugin.name))
+ writer('%s %s' % (to_cli(cmd_plugin.name).ljust(mcl),
+ cmd_plugin.summary))
else:
raise HelpError(topic=name)