Issue 87 in argparse: Serious issues with nested mutex groups in help output

1 view
Skip to first unread message

argp...@googlecode.com

unread,
Sep 14, 2012, 12:21:11 AM9/14/12
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 87 by myselfas...@gmail.com: Serious issues with nested mutex
groups in help output
http://code.google.com/p/argparse/issues/detail?id=87

The following is the code from lines 392 to 409 of the argparse.py code,
where the parentheticals and brackets are being built-up.

==============================================
end = start + len(group._group_actions)
if actions[start:end] == group._group_actions:
for action in group._group_actions:
group_actions.add(action)
if not group.required:
if start in inserts:
inserts[start] += ' ['
else:
inserts[start] = '['
inserts[end] = ']'
else:
if start in inserts:
inserts[start] += ' ('
else:
inserts[start] = '('
inserts[end] = ')'
for i in range(start + 1, end):
inserts[i] = '|'
==============================================

Problem 1: When a nested mutex group is the right-most option of another
mutex group, the right brackets are not right:

usage: GDriveFS Tool [-h] [-u | -a authcode | [-b | -c authcode2]

Problem 2: When a nested mutex group is the left-most option of another
mutex group, there is a missing bar to the right of that nested group, in
the parent.

usage: GDriveFS Tool [-h] [[-b | -c authcode2] -u | -a authcode]

Problem 3: You can fix problem (1) by doing (a), but then there is an extra
bar inside the child mutex on the right, when that child mutex is the
left-most option (b):

a)
Change:
inserts[end] = ']'

To:
if end in inserts:
inserts[end] += '] '
else:
inserts[end] = ']'

b)
usage: GDriveFS Tool [-h] [[-b | -c authcode2 |] -u | -a authcode]

In all likelihood, this will all have to be reflowed due to a flawed (and
difficult-to-decypher) design.

I know it's obnoxious for some uninvited outsider to point out a serious
problem without presenting a solution. I'll work on a potential solution
for you guys if I have time.


argp...@googlecode.com

unread,
Sep 14, 2012, 12:22:11 AM9/14/12
to argpar...@googlegroups.com

Comment #1 on issue 87 by myselfas...@gmail.com: Serious issues with nested
This is in version 1.1, by the way.

argp...@googlecode.com

unread,
Sep 14, 2012, 4:24:30 AM9/14/12
to argpar...@googlegroups.com

Comment #2 on issue 87 by steven.b...@gmail.com: Serious issues with nested
The argparse module is not developed here. Please file issues at
bugs.python.org.

Reply all
Reply to author
Forward
0 new messages