mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
parent
23609d5955
commit
e76b0bbbcc
@ -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)
|
||||
|
||||
|
@ -318,9 +318,12 @@ class APINameSpace(collections.Mapping):
|
||||
self.__enumerate()
|
||||
return iter(self.__plugins)
|
||||
|
||||
def __getitem__(self, key):
|
||||
def get_plugin(self, key):
|
||||
self.__enumerate()
|
||||
plugin = self.__plugins_by_key[key]
|
||||
return self.__plugins_by_key[key]
|
||||
|
||||
def __getitem__(self, key):
|
||||
plugin = self.get_plugin(key)
|
||||
return self.__api._get(plugin)
|
||||
|
||||
def __call__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user