(self, action)
| 512 | return self._fill_text(text, text_width, indent) + '\n\n' |
| 513 | |
| 514 | def _format_action(self, action): |
| 515 | # determine the required width and the entry label |
| 516 | help_position = min(self._action_max_length + 2, |
| 517 | self._max_help_position) |
| 518 | help_width = self._width - help_position |
| 519 | action_width = help_position - self._current_indent - 2 |
| 520 | action_header = self._format_action_invocation(action) |
| 521 | |
| 522 | # ho nelp; start on same line and add a final newline |
| 523 | if not action.help: |
| 524 | tup = self._current_indent, '', action_header |
| 525 | action_header = '%*s%s\n' % tup |
| 526 | |
| 527 | # short action name; start on the same line and pad two spaces |
| 528 | elif len(action_header) <= action_width: |
| 529 | tup = self._current_indent, '', action_width, action_header |
| 530 | action_header = '%*s%-*s ' % tup |
| 531 | indent_first = 0 |
| 532 | |
| 533 | # long action name; start on the next line |
| 534 | else: |
| 535 | tup = self._current_indent, '', action_header |
| 536 | action_header = '%*s%s\n' % tup |
| 537 | indent_first = help_position |
| 538 | |
| 539 | # collect the pieces of the action help |
| 540 | parts = [action_header] |
| 541 | |
| 542 | # if there was help for the action, add lines of help text |
| 543 | if action.help: |
| 544 | help_text = self._expand_help(action) |
| 545 | help_lines = self._split_lines(help_text, help_width) |
| 546 | parts.append('%*s%s\n' % (indent_first, '', help_lines[0])) |
| 547 | for line in help_lines[1:]: |
| 548 | parts.append('%*s%s\n' % (help_position, '', line)) |
| 549 | |
| 550 | # or add a newline if the description doesn't end with one |
| 551 | elif not action_header.endswith('\n'): |
| 552 | parts.append('\n') |
| 553 | |
| 554 | # if there are any sub-actions, add their help as well |
| 555 | for subaction in self._iter_indented_subactions(action): |
| 556 | parts.append(self._format_action(subaction)) |
| 557 | |
| 558 | # return a single string |
| 559 | return self._join_parts(parts) |
| 560 | |
| 561 | def _format_action_invocation(self, action): |
| 562 | if not action.option_strings: |
nothing calls this directly
no test coverage detected