Switch reviewers command to use argparse
optparse is deprecated in python 2.7 and not available starting in python3. This changes the reviewers command to use argparse instead. Change-Id: I76f270b4e998e8cf2a56c12d7bf70c0651c69d16
This commit is contained in:
parent
e305d927e4
commit
93f7506d54
|
@ -16,11 +16,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
import calendar
|
import calendar
|
||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import getpass
|
import getpass
|
||||||
import optparse
|
|
||||||
import prettytable
|
import prettytable
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -238,44 +238,44 @@ def main(argv=None):
|
||||||
if argv is None:
|
if argv is None:
|
||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
|
|
||||||
optparser = optparse.OptionParser()
|
optparser = argparse.ArgumentParser()
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-p', '--project', default='projects/nova.json',
|
'-p', '--project', default='projects/nova.json',
|
||||||
help='JSON file describing the project to generate stats for')
|
help='JSON file describing the project to generate stats for')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-a', '--all', action='store_true',
|
'-a', '--all', action='store_true', default=False,
|
||||||
help='Generate stats across all known projects (*.json)')
|
help='Generate stats across all known projects (*.json)')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-s', '--stable', default='', metavar='BRANCH',
|
'-s', '--stable', default='', metavar='BRANCH',
|
||||||
help='Generate stats for the specified stable BRANCH ("havana") '
|
help='Generate stats for the specified stable BRANCH ("havana") '
|
||||||
'across all integrated projects. Specify "all" for all '
|
'across all integrated projects. Specify "all" for all '
|
||||||
'open stable branches.')
|
'open stable branches.')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-o', '--output', default='-',
|
'-o', '--output', default='-',
|
||||||
help='Where to write output. If - stdout is used and only one output '
|
help='Where to write output. If - stdout is used and only one output '
|
||||||
'format may be given. Otherwise the output format is appended to '
|
'format may be given. Otherwise the output format is appended to '
|
||||||
'the output parameter to generate file names.')
|
'the output parameter to generate file names.')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'--outputs', default=['txt'], action='append',
|
'--outputs', default=['txt'], action='append',
|
||||||
help='Select what outputs to generate. (txt,csv).')
|
help='Select what outputs to generate. (txt,csv).')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-d', '--days', type='int', default=14,
|
'-d', '--days', type=int, default=14,
|
||||||
help='Number of days to consider')
|
help='Number of days to consider')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-u', '--user', default=getpass.getuser(), help='gerrit user')
|
'-u', '--user', default=getpass.getuser(), help='gerrit user')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-P', '--password', default=getpass.getuser(),
|
'-P', '--password', default=getpass.getuser(),
|
||||||
help='gerrit HTTP password')
|
help='gerrit HTTP password')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-k', '--key', default=None, help='ssh key for gerrit')
|
'-k', '--key', default=None, help='ssh key for gerrit')
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'-r', '--csv-rows', default=0, help='Max rows for CSV output',
|
'-r', '--csv-rows', default=0, help='Max rows for CSV output',
|
||||||
type='int', dest='csv_rows')
|
type=int)
|
||||||
optparser.add_option(
|
optparser.add_argument(
|
||||||
'--server', default='review.opendev.org',
|
'--server', default='review.opendev.org',
|
||||||
help='Gerrit server to connect to')
|
help='Gerrit server to connect to')
|
||||||
|
|
||||||
options, args = optparser.parse_args()
|
options = optparser.parse_args()
|
||||||
|
|
||||||
if options.stable:
|
if options.stable:
|
||||||
projects = utils.get_projects_info('projects/stable.json', False)
|
projects = utils.get_projects_info('projects/stable.json', False)
|
||||||
|
|
Loading…
Reference in New Issue