Commit 4aecba8b authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: pak_util: handle Python 3 argparse changes

The required behavior of argparse subparsers changed in Python 3.
Add some code that works in Python 2 & Python 3 to retain the old
behavior.

Bug: 983071
Test: `./pak_util.py` doesn't crash under Python 3
Change-Id: I6820c65e365da662633a2eb4386e4077fedd3174
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771983Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690911}
parent c4901e64
...@@ -100,7 +100,11 @@ def _ListMain(args): ...@@ -100,7 +100,11 @@ def _ListMain(args):
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter) description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
sub_parsers = parser.add_subparsers() # Subparsers are required by default under Python 2. Python 3 changed to
# not required, but didn't include a required option until 3.7. Setting
# the required member works in all versions (and setting dest name).
sub_parsers = parser.add_subparsers(dest='action')
sub_parsers.required = True
sub_parser = sub_parsers.add_parser('repack', sub_parser = sub_parsers.add_parser('repack',
help='Combines several .pak files into one.') help='Combines several .pak files into one.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment