1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-24 11:12:14 +01:00

Merge pull request #1113 from dmach/fix/cmdln-empty-docstring

Do not crash when do_* handler has no docstring
This commit is contained in:
Daniel Mach 2022-08-22 15:21:41 +02:00 committed by GitHub
commit 565797d5a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,16 +143,20 @@ class Cmdln:
self.cmd_map[i] = cmd_func self.cmd_map[i] = cmd_func
self.alias_to_cmd_name_map[i] = cmd_name self.alias_to_cmd_name_map[i] = cmd_name
# split doctext into lines, allow the first line to start at a new line if cmd_func.__doc__:
help_lines = cmd_func.__doc__.lstrip().splitlines() # split doctext into lines, allow the first line to start at a new line
help_lines = cmd_func.__doc__.lstrip().splitlines()
# use the first line as help text # use the first line as help text
help_text = help_lines.pop(0) help_text = help_lines.pop(0)
# use the remaining lines as description # use the remaining lines as description
help_lines = self._remove_leading_spaces_from_lines(help_lines) help_lines = self._remove_leading_spaces_from_lines(help_lines)
help_desc = "\n".join(help_lines) help_desc = "\n".join(help_lines)
help_desc = help_desc.strip() help_desc = help_desc.strip()
else:
help_text = ""
help_desc = ""
if hidden: if hidden:
help_text = argparse.SUPPRESS help_text = argparse.SUPPRESS