Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4A962C0015E for ; Wed, 19 Jul 2023 23:58:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4401686880; Thu, 20 Jul 2023 01:52:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="HSPDTZc1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7594D867F0; Thu, 20 Jul 2023 01:50:45 +0200 (CEST) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6961186675 for ; Thu, 20 Jul 2023 01:50:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-78372b895d6so8085239f.2 for ; Wed, 19 Jul 2023 16:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810638; x=1690415438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6T85rF0qMAwnGYUSxJ8sGLmZr4C1dV/oYTEbFWzsSHA=; b=HSPDTZc1TeiTYBa1aTNToXHqiD5qpFS/1gSDDhJBGn9akW28RK6NVlOwkNv1/RaoUp GIUIUfwWRf7CaCWrQ6LUlSFYSKB6xguDI5rSrQ0J5kv7jO+ITGN2wRAAx1O+NjkCZvOi gWTul3obbHuTMg1XRmxp/Flux4XCaG0kcQ65g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810638; x=1690415438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6T85rF0qMAwnGYUSxJ8sGLmZr4C1dV/oYTEbFWzsSHA=; b=CMh7HJyw3BzB6kNUnoVJqfNApOkGYWX0TxlCfmX7eEtre+Foav0yj4xbMvDFdBUegP n0gkl2sfEknL0h911FtA3EFu9H8DNi1DRTIggDZ6464UmrCc4p2fWnGSwfHfnYC/FK/t igoUdTUUo1Ge6xULucLuaGdG6uyWc6q05kQmdg3lUrxBxrgZHkwR0BfYS2e8SApIbXqd bWAai0mJZlOW1syWjuc8iwv2bq00wb5aulBK/MQEaD1V7YZJR0sgDIoaIHqUlSWbLxuy YpK1QJ0Efaq3WZW3uqxrlbCNdc1kUaJfd/zEovJdLSLni2IK1p8xi/lC9H/LEUQWXyTa 3b5A== X-Gm-Message-State: ABy/qLaR3i8NlbjWSY85hb3vEjPNFGnRjXzA3Yjeqjngquw+0cWHKkhp e67BbLHUvWf4T1ky+Zj5zzMObLiyynBAEexv0Rc= X-Google-Smtp-Source: APBJJlGLqzWU859f22AVcuiesQMXSxSaBsjpHXYyhy9zJedmGcopkpjeOYYTDqV4zVcGRWdH8p8qzQ== X-Received: by 2002:a5d:9393:0:b0:787:6ae:46fa with SMTP id c19-20020a5d9393000000b0078706ae46famr906335iol.1.1689810638039; Wed, 19 Jul 2023 16:50:38 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 52/83] buildman: Create a function to get number of built commits Date: Wed, 19 Jul 2023 17:49:00 -0600 Message-ID: <20230719234953.796101-53-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Move this code into a function. This removes the last pylint error in the control module. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index b388d760ba4a..3a9454cd793c 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -29,7 +29,24 @@ def get_plural(count): """Returns a plural 's' if count is not 1""" return 's' if count != 1 else '' -def get_action_summary(is_summary, commits, selected, step, threads, jobs): + +def count_build_commits(commits, step): + """Calculate the number of commits to be built + + Args: + commits (list of Commit): Commits to build or None + step (int): Step value for commits, typically 1 + + Returns: + Number of commits that will be built + """ + if commits: + count = len(commits) + return (count + step - 1) // step + return 0 + + +def get_action_summary(is_summary, commit_count, selected, threads, jobs): """Return a string summarising the intended action. Args: @@ -43,10 +60,8 @@ def get_action_summary(is_summary, commits, selected, step, threads, jobs): Returns: Summary string. """ - if commits: - count = len(commits) - count = (count + step - 1) // step - commit_str = f'{count} commit{get_plural(count)}' + if commit_count: + commit_str = f'{commit_count} commit{get_plural(commit_count)}' else: commit_str = 'current source' msg = (f"{'Summary of' if is_summary else 'Building'} " @@ -83,8 +98,8 @@ def show_actions(series, why_selected, boards_selected, output_dir, commits = series.commits else: commits = None - print(get_action_summary(False, commits, boards_selected, step, threads, - jobs)) + print(get_action_summary(False, count_build_commits(commits, step), + boards_selected, threads, jobs)) print(f'Build directory: {output_dir}') if commits: for upto in range(0, len(series.commits), step): @@ -494,8 +509,9 @@ def run_builder(builder, commits, board_selected, options): builder.gnu_make = gnu_make if not options.ide: - tprint(get_action_summary(options.summary, commits, board_selected, - options.step, options.threads, options.jobs)) + commit_count = count_build_commits(commits, options.step) + tprint(get_action_summary(options.summary, commit_count, board_selected, + options.threads, options.jobs)) builder.SetDisplayOptions( options.show_errors, options.show_sizes, options.show_detail, -- 2.41.0.487.g6d72f3e995-goog