From patchwork Fri Jul 19 13:06:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Huesca X-Patchwork-Id: 1134049 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45qrqp5FpXz9sBF for ; Fri, 19 Jul 2019 23:06:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 93A2C86A94; Fri, 19 Jul 2019 13:06:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SyVCI3lFyBsC; Fri, 19 Jul 2019 13:06:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 36EE18652A; Fri, 19 Jul 2019 13:06:39 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id CF7D81BF2A6 for ; Fri, 19 Jul 2019 13:06:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id CB4DF858E1 for ; Fri, 19 Jul 2019 13:06:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OxntC1xm1B07 for ; Fri, 19 Jul 2019 13:06:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by hemlock.osuosl.org (Postfix) with ESMTPS id 34E02857BC for ; Fri, 19 Jul 2019 13:06:36 +0000 (UTC) X-Originating-IP: 86.250.200.211 Received: from localhost.localdomain (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: victor.huesca@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id AC8C8240012; Fri, 19 Jul 2019 13:06:34 +0000 (UTC) From: Victor Huesca To: buildroot@buildroot.org Date: Fri, 19 Jul 2019 15:06:28 +0200 Message-Id: <20190719130630.9967-2-victor.huesca@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190719130630.9967-1-victor.huesca@bootlin.com> References: <20190719130630.9967-1-victor.huesca@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 1/3] support/scripts/pkg-stats: improve argparse usage X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Victor Huesca , thomas.petazzoni@bootlin.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 --- support/scripts/pkg-stats | 9 +++------ 1 file 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: