Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serious issues with nested mutex groups in help output #87

Open
GoogleCodeExporter opened this issue Mar 23, 2015 · 2 comments
Open

Serious issues with nested mutex groups in help output #87

GoogleCodeExporter opened this issue Mar 23, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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.

Original issue reported on code.google.com by [email protected] on 14 Sep 2012 at 4:21

@GoogleCodeExporter
Copy link
Author

This is in version 1.1, by the way.

Original comment by [email protected] on 14 Sep 2012 at 4:22

@GoogleCodeExporter
Copy link
Author

The argparse module is not developed here. Please file issues at 
bugs.python.org.

Original comment by [email protected] on 14 Sep 2012 at 8:24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant