Some minor refactorings

This commit is contained in:
Griatch 2020-11-15 11:30:09 +01:00
parent 77c2f556e3
commit 9f11fe50d6

View file

@ -168,29 +168,20 @@ class CmdHelp(Command):
Returns the formatted string, ready to be sent. Returns the formatted string, ready to be sent.
""" """
start_chunk = f"{_SEP}\n" start = f"{_SEP}\n"
title_chunk = f"|CHelp for |w{title}|n" if title else "" title = f"|CHelp for |w{title}|n" if title else ""
aliases_chunk = " |C(aliases: {}|C)|n" \ aliases = (
.format("|C,|n ".join(f"|w{ali}|n" for ali in aliases)) \ " |C(aliases: {}|C)|n".format("|C,|n ".join(f"|w{ali}|n" for ali in aliases))
if aliases else "" if aliases else "")
help_text_chunk = f"\n{dedent(help_text.rstrip())}" \ help_text = (
if help_text else "" f"\n{dedent(help_text.rstrip())}"if help_text else "")
suggested_chunk = \ suggested = (
"\n\n|CSuggested:|n {}" \ "\n\n|CSuggested:|n {}".format(
.format(fill("|C,|n ".join(f"|w{sug}|n" for sug in suggested))) \ fill("|C,|n ".join(f"|w{sug}|n" for sug in suggested)))
if suggested else "" if suggested else "")
end_chunk = f"\n{_SEP}" end = f"\n{_SEP}"
help_entry_chunks = [ return "".join((start, title, aliases, help_text, suggested, end))
start_chunk,
title_chunk,
aliases_chunk,
help_text_chunk,
suggested_chunk,
end_chunk,
]
string = "".join(help_entry_chunks)
return string
def format_help_list(self, hdict_cmds, hdict_db): def format_help_list(self, hdict_cmds, hdict_db):
""" """