aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGravatar Victor Huesca <victor.huesca@bootlin.com>2019-07-19 15:06:28 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-08-01 11:10:41 +0200
commit365aee0f386c4eba78d93c9bcb9e6f737ae5e3cc (patch)
treeac71e2b07ec2f45ff85d9915f1e9b5b9def24148 /support
parent03ef9da6414ab4189723779a553c3c76dce26cb9 (diff)
downloadbuildroot-365aee0f386c4eba78d93c9bcb9e6f737ae5e3cc.tar.gz
buildroot-365aee0f386c4eba78d93c9bcb9e6f737ae5e3cc.tar.bz2
support/scripts/pkg-stats: improve argparse usage
Move the mutual exculsion of the '-n' and '-p' options to be part of the parser instead of being checked in main. Signed-off-by: Victor Huesca <victor.huesca@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'support')
-rwxr-xr-xsupport/scripts/pkg-stats9
1 files changed, 3 insertions, 6 deletions
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index b0be7d919b..d65f609d57 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -23,7 +23,6 @@ import os
from collections import defaultdict
import re
import subprocess
-import sys
import requests # URL checking
import json
import certifi
@@ -700,18 +699,16 @@ def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('-o', dest='output', action='store', required=True,
help='HTML output file')
- parser.add_argument('-n', dest='npackages', type=int, action='store',
+ packages = parser.add_mutually_exclusive_group()
+ packages.add_argument('-n', dest='npackages', type=int, action='store',
help='Number of packages')
- parser.add_argument('-p', dest='packages', action='store',
+ packages.add_argument('-p', dest='packages', action='store',
help='List of packages (comma separated)')
return parser.parse_args()
def __main__():
args = parse_args()
- if args.npackages and args.packages:
- print("ERROR: -n and -p are mutually exclusive")
- sys.exit(1)
if args.packages:
package_list = args.packages.split(",")
else: