Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4504C4338F for ; Fri, 13 Aug 2021 16:39:26 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8221604AC for ; Fri, 13 Aug 2021 16:39:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B8221604AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sancloud.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5311882DD8; Fri, 13 Aug 2021 18:39:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sancloud.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=sancloud.onmicrosoft.com header.i=@sancloud.onmicrosoft.com header.b="k2sQUQZ9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9AE1382D5B; Fri, 13 Aug 2021 18:25:19 +0200 (CEST) Received: from GBR01-LO2-obe.outbound.protection.outlook.com (mail-lo2gbr01on072e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe15::72e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A2B11829C6 for ; Fri, 13 Aug 2021 18:25:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sancloud.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=paul.barker@sancloud.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qqh0Au4yzeguUbQTnd5xmkzf5/3oWyRBGGJQNqWCy0Hge0Ume9Vg9Hx2kIBYNJ95nkEkfXDUmzuhZRKeJPPv8pQBKekrFkVm/VCMEXFNiBAKCzphaWUDLARR/ddWs+JFK2+wNBS3mGCaEarXPmtbHbbPLklqtCthsdwl6FEgcnX1zhOWI6qrvaeV+Ju1p/SDvKPLXXuov6+OvYAr3prMWjWl04Ak4sOsN1wKqS27O28g6vKYSpQEwDaKaYiLvVUFNEbH8ciMA9lJC+cpsFVHwzRRbT0oh3uHqq4EZY3nOhJ0y5HmG3tp8g61eU14GkbEK+R2se85rxtQYgTXhUsqyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JOHCqbPxZRF1dKp/H3ASAYO/BAmsUOR2PJbuzRypypU=; b=IpeAyD7TrmohKNTXZoC7VvRzAvwOHiTxu91ZAWGb9Mqmgie471xHzynhH0PIJmusIGB5uvfLW3nE6XyhwvTC5YEEM4GlzuI5zoEkpRV4yvzNPyA6L28AaIPv4QR1/lyMGg3bJkQMDw73ANXx/MIYfExaSWOZt0SAnwtPXMGWUp8Qxny9sFHwukWcgRCxN4jzGAYP6Q70Nvpafv0jfTdDGvY42gwoNwJPnRXftHBOFFz2u+iG8/VAq1ejmuxWqSg3ZsxQlWc0PtxKQCXou6Yu6yyucbcf4X6mWixN8yZEyMEf8ffyO9ECrUIzByYcMgEAfgpppkWkMP2KeCaOXzHesA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sancloud.com; dmarc=pass action=none header.from=sancloud.com; dkim=pass header.d=sancloud.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sancloud.onmicrosoft.com; s=selector2-sancloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JOHCqbPxZRF1dKp/H3ASAYO/BAmsUOR2PJbuzRypypU=; b=k2sQUQZ9CSe6bkFY0lXPTt26FxjTKRB75D8lntXmmn0lie8dV+UnNWALBj6QMqy7Fi1b0udHCRXPJLzyLKtMVHig0C0DeV//0L8ZF3fHgHvZviUnu8EluNKooijx8lGgFYmgmKHnB3Ju8txKxbcZXYvd1fdednNVZf3FqNQ4g78= Authentication-Results: chromium.org; dkim=none (message not signed) header.d=none;chromium.org; dmarc=none action=none header.from=sancloud.com; Received: from CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:61::19) by CWLP123MB4323.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:e1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Fri, 13 Aug 2021 16:25:12 +0000 Received: from CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM ([fe80::dc2:e929:76be:a8b0]) by CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM ([fe80::dc2:e929:76be:a8b0%7]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 16:25:12 +0000 From: Paul Barker To: Simon Glass , u-boot@lists.denx.de Cc: Paul Barker Subject: [PATCH v2 1/2] tools: Refactor full help printing Date: Fri, 13 Aug 2021 17:24:59 +0100 Message-Id: <20210813162500.11941-2-paul.barker@sancloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210813162500.11941-1-paul.barker@sancloud.com> References: <20210813162500.11941-1-paul.barker@sancloud.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0217.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::13) To CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:61::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from owl.home.b5net.uk (80.7.160.81) by LO2P265CA0217.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13 via Frontend Transport; Fri, 13 Aug 2021 16:25:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01aa4997-fbdc-4cad-a52f-08d95e76ed0c X-MS-TrafficTypeDiagnostic: CWLP123MB4323: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9IhVN//4iTBjlYI8a8ekuOe6DH/shIsGQ6oIzl7dAEJZjb/FzSHYHkajvnoUVB22wejaQayxMUK3Jkv1sgnIV1ctPUSz1HNGqo/m8aVF6iDu4PLWb4FyDMUcKCmKBoaTg5g7Gxhy44GPU03hP5oHagv7GWfFGx1IMbYiX7KwNCdlXpFMcy1LAjH55iZ2+0Ab+GPVfzzjPhVmWVDwxnCvhNWhW9rGLA7i5zOi3gEfjKbjStVlgtL85nYxZHccHK6OhDWeg8xspb6pXVm9JRazeZ3W7aquEGAs3dnkCZq/7DXY2pqvXNtaXkMai8s6a2p955eRTQSUNtTKQ29EeuKpNMfd11DqH9gUMYMxuioNdms2835oQ7Mnehy3VFdagsT3Avt1rNzfhYlEO1VQAY9JArCECmH0Rb6+8mp1App4ptyvkO0N5HNctu5B+iOoUE6YxiVVpTydxDAJ0tofnQU3xYUJS1L5eIyLCXJI0s0zbSYmd7EK960eQ3yLGgpnFjMvaes1FnmNV2+2AFUuGLeMJxaqNZeJAJ+D6+BdiFfDBOHCeiiuAczjFuRxfTK2oGau5fU8Lj9Xx04jclOQMwt+2lW8Xx32j0K78omjW4epHtSAnMg0ZKcUUW1QBUCv6YyHT4CBQ5RtPFHyolUVutzKJbMCwg6hF9zEacNvdPHdtfixSJsWA1Iy4WstjLfCBomjHbeNpEoXfqdXwDgycrIjqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(39830400003)(376002)(346002)(52116002)(6506007)(38100700002)(316002)(38350700002)(186003)(36756003)(26005)(44832011)(107886003)(6512007)(2906002)(2616005)(83380400001)(86362001)(6666004)(4326008)(8676002)(508600001)(6486002)(66946007)(66556008)(1076003)(8936002)(66476007)(5660300002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aoUTKINpIp/yc94RCosH7XUJIFAv0FN6jzEIepjeJT7jNP6p0WzDhKaUfwNy?= =?us-ascii?Q?tgLdMXaSTZM4bpH9/VEj2INKwr1oe7O7kn0zUE0riT8GnbyD1oejHWFGyQTP?= =?us-ascii?Q?kYiuNSNvc+EU7oYCCDvPB4yQadhLOm4RpDG9Or+2VTYmBtjFx0MZ2nkuGum1?= =?us-ascii?Q?zBu3fxPhBAobBDPT9V3eTfTqLym72+ie550bQL2Jrs+ZSDae9hDi4w10B6A9?= =?us-ascii?Q?rH942IFAiszn5/4yfvYRURoxbetsoblO+T/ptx/0S9VnLGvZKbwM6MdZuMp4?=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k/chjbQHr6zhT8UiNxcwSQTiTWsL0Q?= =?us-ascii?Q?szE/Bk+0uqbFJLGAKvShHMRwzckQC7E8uI+LcOtkWMXaq21++Ee4pUgtEwh9?= =?us-ascii?Q?5ithU02A97cCYYiqhLvsmi+QzzpBqShWwpRczP4WYZu6Yr3buUJrpO7Asj9l?= =?us-ascii?Q?PsjRv1yqnRHXQt2uznK6yDMz?= X-OriginatorOrg: sancloud.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01aa4997-fbdc-4cad-a52f-08d95e76ed0c X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB2241.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 16:25:12.7135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 840be37c-244a-450e-9bcc-2064862de1f4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IwwbXOGW6N3/djrYeIfywsjGN/EGkPxtZQ/xFmG+s1nYSze+RneohIOie0KoZPrtnBiYTDT/D4VWn/5+AwVFaZOdQNrG01YhPtmk7f5eUt0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB4323 X-Mailman-Approved-At: Fri, 13 Aug 2021 18:39:07 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Collect the code for printing the full help message of patman, buildman and binman into a single function in patman.tools. Signed-off-by: Paul Barker --- tools/binman/control.py | 9 +++------ tools/buildman/control.py | 10 ++++------ tools/patman/main.py | 12 ++++-------- tools/patman/tools.py | 13 +++++++++++++ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index dcba02ff7f..0dbcbc28e9 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -565,12 +565,9 @@ def Binman(args): global state if args.full_help: - pager = os.getenv('PAGER') - if not pager: - pager = 'more' - fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), - 'README.rst') - command.Run(pager, fname) + tools.PrintFullHelp( + os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README.rst') + ) return 0 # Put these here so that we can import this module without libfdt diff --git a/tools/buildman/control.py b/tools/buildman/control.py index a98d1b4c06..fd9664c85d 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -16,6 +16,7 @@ from patman import command from patman import gitutil from patman import patchstream from patman import terminal +from patman import tools from patman.terminal import Print def GetPlural(count): @@ -133,12 +134,9 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, global builder if options.full_help: - pager = os.getenv('PAGER') - if not pager: - pager = 'more' - fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), - 'README') - command.Run(pager, fname) + tools.PrintFullHelp( + os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README') + ) return 0 gitutil.Setup() diff --git a/tools/patman/main.py b/tools/patman/main.py index 04e37a5931..e5be28e331 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -28,6 +28,7 @@ from patman import settings from patman import terminal from patman import test_util from patman import test_checkpatch +from patman import tools epilog = '''Create patches from commits in a branch, check them and email them as specified by tags you place in the commits. Use -n to do a dry run first.''' @@ -170,14 +171,9 @@ elif args.cmd == 'send': fd.close() elif args.full_help: - pager = os.getenv('PAGER') - if not pager: - pager = shutil.which('less') - if not pager: - pager = 'more' - fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), - 'README') - command.Run(pager, fname) + tools.PrintFullHelp( + os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README') + ) else: # If we are not processing tags, no need to warning about bad ones diff --git a/tools/patman/tools.py b/tools/patman/tools.py index 877e37cd8d..96882264a2 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -581,3 +581,16 @@ def ToHexSize(val): hex value of size, or 'None' if the value is None """ return 'None' if val is None else '%#x' % len(val) + +def PrintFullHelp(fname): + """Print the full help message for a tool using an appropriate pager. + + Args: + fname: Path to a file containing the full help message + """ + pager = os.getenv('PAGER') + if not pager: + pager = shutil.which('less') + if not pager: + pager = 'more' + command.Run(pager, fname) -- 2.31.1