From 93f7506d54b7cf2abd33ebf6065855f0b10a7b6c Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 4 Nov 2019 11:12:53 -0500 Subject: [PATCH] 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 --- reviewstats/cmd/reviewers.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/reviewstats/cmd/reviewers.py b/reviewstats/cmd/reviewers.py index 2be584c..e232b8a 100755 --- a/reviewstats/cmd/reviewers.py +++ b/reviewstats/cmd/reviewers.py @@ -16,11 +16,11 @@ # under the License. +import argparse import calendar import csv import datetime import getpass -import optparse import prettytable import sys @@ -238,44 +238,44 @@ def main(argv=None): if argv is None: argv = sys.argv - optparser = optparse.OptionParser() - optparser.add_option( + optparser = argparse.ArgumentParser() + optparser.add_argument( '-p', '--project', default='projects/nova.json', help='JSON file describing the project to generate stats for') - optparser.add_option( - '-a', '--all', action='store_true', + optparser.add_argument( + '-a', '--all', action='store_true', default=False, help='Generate stats across all known projects (*.json)') - optparser.add_option( + optparser.add_argument( '-s', '--stable', default='', metavar='BRANCH', help='Generate stats for the specified stable BRANCH ("havana") ' 'across all integrated projects. Specify "all" for all ' 'open stable branches.') - optparser.add_option( + optparser.add_argument( '-o', '--output', default='-', help='Where to write output. If - stdout is used and only one output ' 'format may be given. Otherwise the output format is appended to ' 'the output parameter to generate file names.') - optparser.add_option( + optparser.add_argument( '--outputs', default=['txt'], action='append', help='Select what outputs to generate. (txt,csv).') - optparser.add_option( - '-d', '--days', type='int', default=14, + optparser.add_argument( + '-d', '--days', type=int, default=14, help='Number of days to consider') - optparser.add_option( + optparser.add_argument( '-u', '--user', default=getpass.getuser(), help='gerrit user') - optparser.add_option( + optparser.add_argument( '-P', '--password', default=getpass.getuser(), help='gerrit HTTP password') - optparser.add_option( + optparser.add_argument( '-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', - type='int', dest='csv_rows') - optparser.add_option( + type=int) + optparser.add_argument( '--server', default='review.opendev.org', help='Gerrit server to connect to') - options, args = optparser.parse_args() + options = optparser.parse_args() if options.stable: projects = utils.get_projects_info('projects/stable.json', False)