diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2014-04-11 16:59:50 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2014-04-11 17:02:18 +0900 |
commit | 39f7906b5774243e6fe9fb622dcec37d0cef3ca0 (patch) | |
tree | fa90e56178a3cd899a1470144a646b2bc7e6b0a8 /rest_example.py | |
parent | a76db4cfc83d4cf7a52d045e4df82ec8b1e3f562 (diff) | |
download | pygerrit-39f7906b5774243e6fe9fb622dcec37d0cef3ca0.tar.gz |
Fix up usage of argparse in examples
Since a76db4cfc83d4cf7a52d045e4df82ec8b1e3f562 it is broken.
- Use ArgumentDefaultsHelpFormatter to automatically show default
values for the options.
- Remove hard-coded 'default' information from help texts.
- Add a metavar for the ssh event timeout option.
- Integer arguments must now be specified as `int` rather than
`'int'` with quotation marks.
- Fix calls to `parser.parse_args`, which now returns a single
value rather than a tuple.
Change-Id: If5cf4e2d1f4014a60f7a7634d43df12b788bc7b4
Diffstat (limited to 'rest_example.py')
-rwxr-xr-x | rest_example.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/rest_example.py b/rest_example.py index 825ed7c..1b69c00 100755 --- a/rest_example.py +++ b/rest_example.py @@ -25,8 +25,8 @@ """ Example of using the Gerrit client REST API. """ -import logging import argparse +import logging import sys from requests.auth import HTTPBasicAuth, HTTPDigestAuth @@ -45,7 +45,9 @@ from pygerrit.rest.auth import HTTPDigestAuthFromNetrc, HTTPBasicAuthFromNetrc def _main(): descr = 'Send request using Gerrit HTTP API' - parser = argparse.ArgumentParser(description=descr) + parser = argparse.ArgumentParser( + description=descr, + formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-g', '--gerrit-url', dest='gerrit_url', required=True, help='gerrit server url') @@ -67,7 +69,7 @@ def _main(): action='store_true', help='enable verbose (debug) logging') - (options, _args) = parser.parse_args() + options = parser.parse_args() level = logging.DEBUG if options.verbose else logging.INFO logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', |