mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-08-01 07:27:43 +00:00
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>
This commit is contained in:
parent
03ef9da641
commit
365aee0f38
@ -23,7 +23,6 @@ import os
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import requests # URL checking
|
import requests # URL checking
|
||||||
import json
|
import json
|
||||||
import certifi
|
import certifi
|
||||||
@ -700,18 +699,16 @@ def parse_args():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-o', dest='output', action='store', required=True,
|
parser.add_argument('-o', dest='output', action='store', required=True,
|
||||||
help='HTML output file')
|
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')
|
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)')
|
help='List of packages (comma separated)')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def __main__():
|
def __main__():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
if args.npackages and args.packages:
|
|
||||||
print("ERROR: -n and -p are mutually exclusive")
|
|
||||||
sys.exit(1)
|
|
||||||
if args.packages:
|
if args.packages:
|
||||||
package_list = args.packages.split(",")
|
package_list = args.packages.split(",")
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user