(PEP8) Whitespace/indent, split lines in help.py

This commit is contained in:
BlauFeuer 2017-08-02 16:14:55 -04:00 committed by GitHub
parent 340ebb688d
commit e3aa3ce7c6

View file

@ -198,7 +198,8 @@ class CmdHelp(Command):
# retrieve all available commands and database topics
all_cmds = [cmd for cmd in cmdset if self.check_show_help(cmd, caller)]
all_topics = [topic for topic in HelpEntry.objects.all() if topic.access(caller, 'view', default=True)]
all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower() for topic in all_topics]))
all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower()
for topic in all_topics]))
if query in ("list", "all"):
# we want to list all available help entries, grouped by category
@ -222,7 +223,8 @@ class CmdHelp(Command):
if suggestion_maxnum > 0:
vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories
[vocabulary.extend(cmd.aliases) for cmd in all_cmds]
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum)
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff,
maxnum=suggestion_maxnum)
if sugg != query]
if not suggestions:
suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)]
@ -249,8 +251,9 @@ class CmdHelp(Command):
# try to see if a category name was entered
if query in all_categories:
self.msg_help(self.format_help_list({query:[cmd.key for cmd in all_cmds if cmd.help_category==query]},
{query:[topic.key for topic in all_topics if topic.help_category==query]}))
self.msg_help(self.format_help_list({query: [cmd.key for cmd in all_cmds if cmd.help_category == query]},
{query: [topic.key for topic in all_topics
if topic.help_category == query]}))
return
# no exact matches found. Just give suggestions.
@ -264,6 +267,7 @@ def _loadhelp(caller):
else:
return ""
def _savehelp(caller, buffer):
entry = caller.db._editing_help
caller.msg("Saved help entry.")
@ -275,6 +279,7 @@ def _quithelp(caller):
caller.msg("Closing the editor.")
del caller.db._editing_help
class CmdSetHelp(COMMAND_DEFAULT_CLASS):
"""
Edit the help database.
@ -307,7 +312,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
help_category = "Building"
def func(self):
"Implement the function"
"""Implement the function"""
switches = self.switches
lhslist = self.lhslist
@ -352,7 +357,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
else:
helpentry = create.create_help_entry(topicstr,
self.rhs, category=category,
locks=lockstring,aliases=aliases)
locks=lockstring, aliases=aliases)
self.caller.db._editing_help = helpentry
EvEditor(self.caller, loadfunc=_loadhelp, savefunc=_savehelp,
@ -406,7 +411,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
# no old entry. Create a new one.
new_entry = create.create_help_entry(topicstr,
self.rhs, category=category,
locks=lockstring,aliases=aliases)
locks=lockstring, aliases=aliases)
if new_entry:
self.msg("Topic '%s'%s was successfully created." % (topicstr, aliastxt))
if 'edit' in switches: