All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, John Snow <jsnow@redhat.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH 01/22] scripts/get_maintainer.py: minimal argument parsing
Date: Mon, 23 Nov 2026 10:00:52 +0000	[thread overview]
Message-ID: <awQO1JtvT429LQRT@redhat.com> (raw)
In-Reply-To: <20261120200511.822573-2-alex.bennee@linaro.org>

On Fri, Nov 20, 2026 at 08:04:49PM +0000, Alex Bennée wrote:
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> 
> ---
> v3
>   - treat dir as valid as well (as git ls-files lists it)
>   - move arg parse into own function (parse_args)
>   - set files nargs as + for more flexibility
>   - use python3
> ---
>  scripts/get_maintainer.py | 49 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
>  create mode 100755 scripts/get_maintainer.py
> 
> diff --git a/scripts/get_maintainer.py b/scripts/get_maintainer.py
> new file mode 100755
> index 00000000000..47673a5013f
> --- /dev/null
> +++ b/scripts/get_maintainer.py
> @@ -0,0 +1,49 @@
> +#!/usr/bin/env python3
> +#
> +# get_maintainer.py: Print selected MAINTAINERS information
> +#
> +# usage: scripts/get_maintainer.py [OPTIONS] <patch>
> +#        scripts/get_maintainer.py [OPTIONS] -f <file>
> +#
> +# (c) 2025, Alex Bennée <alex.bennee@linaro.org>
> +#           based on get_maintainers.pl
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +from argparse import ArgumentParser, ArgumentTypeError
> +from os import path

This shouldn't be needed if you're intending to use pathlib.

> +from pathlib import Path
> +
> +
> +def valid_file_path(arg):
> +    """
> +    Checks if arg exists and is a regular file or raises ArgumentTypeError.
> +    """

IIUC, if you add add "type=Path" to the group.add_argument() call in
parse_args, then you can assume 'arg' is a pathlib.Path and so....


> +    if not path.exists(arg):

  arg.exists()

> +        raise ArgumentTypeError(f"File '{arg}' does not exist.")
> +    if not path.isfile(arg) and not path.isdir(arg):

  not arg.is_file()  and not arg.is_dir()

> +        raise ArgumentTypeError(f"Path '{arg}' is not a regular file.")
> +    return Path(path.abspath(arg))

   return arg.absolute()

> +
> +
> +def parse_args():
> +    """
> +    Create and parse the arguments.
> +    """
> +    parser = ArgumentParser(description='Extract maintainer information. ')
> +
> +    # We can either specify patches or an individual file
> +    group = parser.add_mutually_exclusive_group()
> +    group.add_argument('patch', nargs='*', type=valid_file_path,
> +                       help='path to patch file')

Personally, I'd put the final positional args after all the option args
but that's a bit bikeshedding.

> +    group.add_argument('-f', '--file', type=valid_file_path, nargs = "+",
> +                       help='path to source file(s)')


> +    return parser.parse_args()
> +
> +def main():
> +
> +    args = parse_args()
> +
> +if __name__ == '__main__':
> +    main()
> -- 
> 2.47.3
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-11-23 10:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 20:04 [PATCH 00/22] MAINTAINER updates and get_maintainer.py Alex Bennée
2026-11-20 20:04 ` [PATCH 01/22] scripts/get_maintainer.py: minimal argument parsing Alex Bennée
2026-11-23 10:00   ` Daniel P. Berrangé [this message]
2026-12-01 14:05     ` Alex Bennée
2026-11-20 20:04 ` [PATCH 02/22] scripts/get_maintainer.py: resolve the source path Alex Bennée
2026-11-20 20:04 ` [PATCH 03/22] scripts/get_maintainer.py: initial parsing of MAINTAINERS Alex Bennée
2026-11-20 20:04 ` [PATCH 04/22] scripts/get_maintainer.py: add support for -f Alex Bennée
2026-11-20 20:04 ` [PATCH 05/22] scripts/get_maintainer.py: add support reading patch files Alex Bennée
2026-11-20 20:04 ` [PATCH 06/22] scripts/get_maintainer.py: add keyword (K:) support Alex Bennée
2026-11-20 20:04 ` [PATCH 07/22] scripts/get_maintainer.py: implement basic git fallback support Alex Bennée
2026-11-20 20:04 ` [PATCH 08/22] scripts/get_maintainer.py: add --list-[maintained|reviewed]-by Alex Bennée
2026-11-20 20:04 ` [PATCH 09/22] scripts/get_maintainer.py: add --file-summary option Alex Bennée
2026-11-20 20:04 ` [PATCH 10/22] scripts/get_maintainer.py: optimise glob matching with Paths Alex Bennée
2026-11-20 20:04 ` [PATCH 11/22] scripts/get_maintainer.py: add support for gitlab handles Alex Bennée
2026-11-20 20:05 ` [PATCH 12/22] scripts/get_maintainer.py: implement --noroles/--norolestats Alex Bennée
2026-11-20 20:05 ` [PATCH 13/22] scripts/get_maintainer.py: expand --validate output to CSV summary Alex Bennée
2026-11-20 20:05 ` [PATCH 14/22] scripts/get_maintainer.py: add --list-maintainers Alex Bennée
2026-11-20 20:05 ` [PATCH 15/22] scripts/get_maintainer.py: add --list-absent-maintainers-since Alex Bennée
2026-11-20 20:05 ` [PATCH 16/22] scripts/maintainer: add plot-maintainer-experience.py Alex Bennée
2026-11-20 20:05 ` [PATCH 17/22] gitlab: add a check-maintainers task Alex Bennée
2026-11-20 20:05 ` [PATCH 18/22] MAINTAINERS: update Daniel's entries to be consistent Alex Bennée
2026-11-20 20:05 ` [PATCH 19/22] MAINTAINERS: make Collin's entries consistent with .mailmap Alex Bennée
2026-11-20 20:05 ` [PATCH 20/22] MAINTAINERS: make LIU's entries consistent Alex Bennée
2026-11-21  7:40   ` LIU Zhiwei
2026-11-20 20:05 ` [PATCH 21/22] MAINTAINERS: use consistent capitalisation for Alistair Alex Bennée
2026-11-22 17:34   ` Philippe Mathieu-Daudé
2026-11-23  1:05   ` Alistair Francis
2026-11-20 20:05 ` [PATCH 22/22] MAINTAINERS: update security reporting links Alex Bennée
2026-11-23  9:50   ` Daniel P. Berrangé
2026-11-23 17:31 ` [PATCH 00/22] MAINTAINER updates and get_maintainer.py Pierrick Bouvier

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=awQO1JtvT429LQRT@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=crosa@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.