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 D1FB7C0015E for ; Sun, 16 Jul 2023 00:45:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2141286607; Sun, 16 Jul 2023 02:39:57 +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="nfygn6hB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 301CB86633; Sun, 16 Jul 2023 02:38:16 +0200 (CEST) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 C79F4862E2 for ; Sun, 16 Jul 2023 02:37:59 +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-xd2e.google.com with SMTP id ca18e2360f4ac-78374596182so147417139f.0 for ; Sat, 15 Jul 2023 17:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467878; x=1692059878; 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=KBQAi2yBz7tWhn8jBSHX5vPtVb50fL7MIMbr4SUA4sk=; b=nfygn6hBPU6tBT3a0lpzgrcoXmbwLAngaYsdu5ba+70V73pX8vHcmZl3dzJlsVMJVF ulxpZLBPi6ScTQfh3PRoBD8Mmi9RdXOGLr3Yk0QYLMiiELpeAoYZ6NZSkFBVfXuip7rn T4Dk3mPLL3xsZvUOzTGqPF7MaIk65hE87W4Qk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467878; x=1692059878; 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=KBQAi2yBz7tWhn8jBSHX5vPtVb50fL7MIMbr4SUA4sk=; b=iKz66fdlpG6sadjBb+9H8+z9ha0dUty2Ev+jaNxPRsOuerg17OUH3rQJVrKWeXIXdJ RSKxxsbaPLu5guSISK2G4ZA/Ux3GJqcpjEm68fCO7fAXvtPbX1qRPg8vDhioLOBpmsHI m8LvTYCPIxDuxcPCKfx4r0etXnn389kO+c4z5Jrc7FG5LcKV1Cu60RU/XOzIkrlsbaj4 5k/9xSRGCP6TjaWy6eOEvqDkeC13mHzNOJEjyEwcCkAcdOcwzdG+OGEn+37rEbslxPmn qtBRc5berBS9g26NVkefBaWNy0algy0hNN/9hXuR9qfBumsf9v2G6+9tJN0X5L6mSU0I jKcQ== X-Gm-Message-State: ABy/qLZA0IY+bDffabPco03pLyPuMGU7e2r0L2a9blJFX5hdjVVfRgVI 2dxjF30DHL31/U/HvTJMXTr/IQ7uMb+Wr9O1yvM= X-Google-Smtp-Source: APBJJlHLinMvug0TZGVZO2XnO+QCj10JmQizsKMoxqO1qFgYjQFk3VapIEqVLZoQfNMEzfMI8xNKgg== X-Received: by 2002:a5e:aa10:0:b0:783:6906:a32c with SMTP id s16-20020a5eaa10000000b007836906a32cmr7929053ioe.16.1689467878400; Sat, 15 Jul 2023 17:37:58 -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 t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:58 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 50/81] buildman: Create a function to get number of built commits Date: Sat, 15 Jul 2023 18:36:18 -0600 Message-ID: <20230716003718.231903-51-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-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.455.g037347b96a-goog