paul j3 added the comment: Here's a patch that takes a different approach - rewrite _format_actions_usage() so it formats groups (and unattached actions) directly.
It uses the same logic to determine when to format a group, but then it calls _format_group_usage() to format the group, without the error prone insert and cleanup business. And by keeping a list of the parts, it avoids the complications of parsing the text. The only cleanup regex removes () from single element groups. In the nested get_lines function, I added 'line and' to if line and line_len + 1 + len(part) > text_width: so it does not create a blank line before an extra long entry (e.g. 'c'*76). I'm using the _format_group_usage() and _format_just_actions_usage() in the Issue 10984 MultiGroupFormatter, just rearranging the logic in its _format_actions_usage() method. That patch could be rewritten to depend on this one. This patch also fixes http://bugs.python.org/issue18349, since the metavar is never parsed. ---------- Added file: http://bugs.python.org/file30941/format_usage.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11874> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com