From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, "Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Jason Wang" <jasowang@redhat.com>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Laurent Vivier" <laurent@vivier.eu>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Subject: Re: [PATCH 1/7] gitlab: use argparse in check-units script
Date: Thu, 10 Jul 2025 13:48:58 +0300 [thread overview]
Message-ID: <CAAjaMXbhWW-TX8zW8nNu77Oy0_v5W6+xT=cGeonvxPmdFwRCzA@mail.gmail.com> (raw)
In-Reply-To: <20250710104531.3099313-2-alex.bennee@linaro.org>
On Thu, Jul 10, 2025 at 1:46 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Modernise the argument parsing so we can easily add to the script.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> .gitlab-ci.d/check-units.py | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/.gitlab-ci.d/check-units.py b/.gitlab-ci.d/check-units.py
> index 268a4118d5..cdc62ae5ee 100755
> --- a/.gitlab-ci.d/check-units.py
> +++ b/.gitlab-ci.d/check-units.py
> @@ -8,8 +8,10 @@
> # SPDX-License-Identifier: GPL-2.0-or-later
>
> from os import access, R_OK, path
> -from sys import argv, exit
> +from sys import exit
> import json
> +import argparse
> +from pathlib import Path
> from collections import Counter
>
>
> @@ -51,16 +53,17 @@ def analyse_units(build_units):
>
>
> if __name__ == "__main__":
> - if len(argv) != 2:
> - script_name = path.basename(argv[0])
> - print(f"Usage: {script_name} <path_to_compile_commands.json>")
> - exit(1)
> + parser = argparse.ArgumentParser(
> + description="analyse number of build units in compile_commands.json")
> + parser.add_argument("cc_path", type=Path, default=None,
> + help="Path to compile_commands.json")
> +
> + args = parser.parse_args()
>
> - cc_path = argv[1]
> - if path.isfile(cc_path) and access(cc_path, R_OK):
> - units = extract_build_units(cc_path)
> + if path.isfile(args.cc_path) and access(args.cc_path, R_OK):
> + units = extract_build_units(args.cc_path)
> analyse_units(units)
> exit(0)
> else:
> - print(f"{cc_path} doesn't exist or isn't readable")
> + print(f"{args.cc_path} doesn't exist or isn't readable")
> exit(1)
> --
> 2.47.2
>
>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
next prev parent reply other threads:[~2025-07-10 10:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 10:45 [PATCH 0/7] maintainer updates for 10.1 softfreeeze (gitlab, plugins, docs) pre-PR Alex Bennée
2025-07-10 10:45 ` [PATCH 1/7] gitlab: use argparse in check-units script Alex Bennée
2025-07-10 10:48 ` Manos Pitsidianakis [this message]
2025-07-10 10:45 ` [PATCH 2/7] gitlab: add -n option to check_units Alex Bennée
2025-07-10 10:57 ` Manos Pitsidianakis
2025-07-10 10:45 ` [PATCH 3/7] contrib/plugins/execlog: Add tab to the separator search of insn_disas Alex Bennée
2025-07-10 15:22 ` Pierrick Bouvier
2025-07-10 10:45 ` [PATCH 4/7] target/alpha: Add GDB XML feature file Alex Bennée
2025-07-10 10:45 ` [PATCH 5/7] plugins: fix inclusion of user-mode APIs Alex Bennée
2025-07-10 15:22 ` Pierrick Bouvier
2025-07-10 10:45 ` [PATCH 6/7] docs: use :kbd: role in sphinx docs Alex Bennée
2025-07-10 10:45 ` [PATCH 7/7] docs/system: clean-up formatting of virtio-net-failover Alex Bennée
2025-07-10 10:59 ` Manos Pitsidianakis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAjaMXbhWW-TX8zW8nNu77Oy0_v5W6+xT=cGeonvxPmdFwRCzA@mail.gmail.com' \
--to=manos.pitsidianakis@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=jasowang@redhat.com \
--cc=laurent@vivier.eu \
--cc=ma.mandourr@gmail.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=riku.voipio@iki.fi \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).