From nobody Sun Jan 25 12:09:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1769180398; cv=none; d=zohomail.com; s=zohoarc; b=YNxEZLDgLriCpDfnyHavUML6lkHz05LUKQodtuCcmqWCDA7IlSa4md4e1tUtWNLKTSmxIoit+qXEb2/QtlkYvqcm/qA0IiHMC8os6M74RTjzpqWs/rEYPoMlaFrmYuDLkwWn7lznvp5db1dAvVjG7vW8RluO3qkVQbWYKOsQBx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769180398; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hoccyFN4VSFNY3IFMb9lpWrE3hrQlhyVLovZvI9LP+I=; b=iI5zLDXspiQUnp6pgKE+RgYcE5PRXlrlA3ofSb6b00r9e54fnvsUK9qgq1Bll7anbo3S0pkXabp/KwCQx8buyBq9pcYU/Br0ISdWb6jd1gC0D1K8s8VYUqYKbHIlxAfzTMlWUfXPcnCTzRSuGVxxJr21HpdFDtkajMHtYmPiM6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769180398880309.42611886783345; Fri, 23 Jan 2026 06:59:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjIc6-0004MM-WB; Fri, 23 Jan 2026 09:58:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjIby-0004I4-72 for qemu-devel@nongnu.org; Fri, 23 Jan 2026 09:58:11 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vjIbv-0007nQ-7Z for qemu-devel@nongnu.org; Fri, 23 Jan 2026 09:58:09 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-42fbc305882so1401183f8f.0 for ; Fri, 23 Jan 2026 06:58:05 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1f742d6sm7017768f8f.30.2026.01.23.06.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 06:57:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6AF4C5F94A; Fri, 23 Jan 2026 14:57:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769180285; x=1769785085; darn=nongnu.org; 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=hoccyFN4VSFNY3IFMb9lpWrE3hrQlhyVLovZvI9LP+I=; b=rHule8hSpdeS+CGe95GaOtlSrUrqjLfFc90j9NxUZMrCmygC5zsu1vMfOPxhP9MWoK HeCLl2E7kEkmD00IYauw+buSV/W37jp6WMvDGTVbORRiiH7drmpD9e3oU0N948OJBXR1 h0Evze3qrSPf36miZDYc3Ucs9JsDskIiDUO8jGFsh0O12xgZSyO7Nq9GB6H4FMQqfy69 pRfMdSDld2YuEekGAdjz/OJ6LiArIE8uHWupygzRRv5w2jxbaaMx+6dQcbe3DPADJowj 7cSCEnrNzmxjnGvmXdsBMZpFb13cjC7Y3UtgnbDPo7Ya2xNZ70Y2/BoryopgkWR+LM4j zU/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769180285; x=1769785085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hoccyFN4VSFNY3IFMb9lpWrE3hrQlhyVLovZvI9LP+I=; b=H19Dg7OG9sfEJDafhOV9Xbg9wHCucrN4sEa7HSQAYqWDOUONEqZs0M2w+2b0uT1g/n ZVxP9UytRo7uSb9JIkU/5TQ1jfmddaYmyQoSPZLOvUQnb3OZshbLJE0wou+yvoqj3Xh5 nhIz/SOEm6VGLZH7WHVBa6Xytp4+MCQ58qxfFfJmc3s52Yp1M/rG1lIxvw/t5EFoAj76 GBkTP2yZ5WOR5vOyGDkI4u76WMr2BFUuN4QWvlmA4K3qGs/a+TJbuBlxV2AJQQ1iNQTL NjnZwV3m8SoaFUHD3kr96t/JJxEtmreCLCpnCfr/wiKg8CmwHYPhPQpeU8csFJ4vLsMj jA6w== X-Gm-Message-State: AOJu0YyeUi0+Dx7jtlqrxqbJT777L8c8NE5QNHJ2bJF56fQsgD52NQzc 43fmsA/c8P64Ho6aFYCxlA8nBfOh7vtE+GKvmSGdFK9oCB3LknKcWp90trCZp9CM3VA= X-Gm-Gg: AZuq6aKCfX4Jjdg741b7KwB69jnVWbcKcl6lABzb1cMp69jgjUjKyMR+cRFhl0QWHXb R3x8uPRjNMDujuELu11KBi88AMCkqYlqr6u3WBn2Ke2ehaFd71XRonxm5L3/Gn8a9vpzFGcvAmj zICU/Jh+etpMkN1W/ECqC57BzGL11BUZYP2ZVQAcV3b0alZLWI7UpKFJEDzsSVPiSmRYiYCA3yJ Ado242bWlASYGNf6XT6uPB9BnfVqHjTYTZLu7EC4Rl8OSEsmxItuM4kHBbL+DzEJvO8n+XVwFZa YtQEWBOYSBKxnhdB7mgffzAfVDU3jsFR9zG9AD5KPn4HyqTvVSDRJeUTaty0q7JYHk0TWAuUQoj 24dX5dU4xU3b2/+dsnL2vsz7RNiYxQdBp48inkxgzwCX20XJKp+dzEZNexMp6U4C2PjzJC701+t 7gvzVdFiE1n+ZR X-Received: by 2002:a05:6000:2913:b0:430:fbe1:3822 with SMTP id ffacd0b85a97d-435b1621b48mr6927553f8f.54.1769180284807; Fri, 23 Jan 2026 06:58:04 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mauro Carvalho Chehab , Joe Perches , John Snow Subject: [RFC PATCH v2 11/16] scripts/get_maintainer.py: initial parsing of MAINTAINERS Date: Fri, 23 Jan 2026 14:57:44 +0000 Message-ID: <20260123145750.1200879-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123145750.1200879-1-alex.bennee@linaro.org> References: <20260123145750.1200879-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1769180400038154100 Add the basic infrastructure to parse MAINTAINERS and generate a list of MaintainerSection objects we can use later. Add a --validate argument so we can use the script to ensure MAINTAINERS is always parse-able in our CI. Signed-off-by: Alex Benn=C3=A9e --- v2 - add __str__ function for formatting Person --- scripts/get_maintainer.py | 168 +++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 1 deletion(-) diff --git a/scripts/get_maintainer.py b/scripts/get_maintainer.py index c02bf4f5b0e..696a5b55d8d 100755 --- a/scripts/get_maintainer.py +++ b/scripts/get_maintainer.py @@ -10,9 +10,159 @@ # # SPDX-License-Identifier: GPL-2.0-or-later =20 -from argparse import ArgumentParser, ArgumentTypeError +from argparse import ArgumentParser, ArgumentTypeError, BooleanOptionalAct= ion from os import path from pathlib import Path +from enum import StrEnum, auto +from re import compile as re_compile + +# +# Subsystem MAINTAINER entries +# +# The MAINTAINERS file is an unstructured text file where the +# important information is in lines that follow the form: +# +# X: some data +# +# where X is a documented tag and the data is variously an email, +# path, regex or link. Other lines should be ignored except the +# preceding non-blank or underlined line which represents the name of +# the "subsystem" or general area of the project. +# +# A blank line denominates the end of a section. +# + +tag_re =3D re_compile(r"^([A-Z]):") + + +class UnhandledTag(Exception): + "Exception for unhandled tags" + + +class BadStatus(Exception): + "Exception for unknown status" + + +class Status(StrEnum): + "Maintenance status" + + UNKNOWN =3D auto() + SUPPORTED =3D 'Supported' + MAINTAINED =3D 'Maintained' + ODD_FIXES =3D 'Odd Fixes' + ORPHAN =3D 'Orphan' + OBSOLETE =3D 'Obsolete' + + @classmethod + def _missing_(cls, value): + # _missing_ is only invoked by the enum machinery if 'value' does = not + # match any existing enum member's value. + # So, if we reach this point, 'value' is inherently invalid for th= is enum. + raise BadStatus(f"'{value}' is not a valid maintenance status.") + + +person_re =3D re_compile(r"^(?P[^<]+?)\s*<(?P[a-zA-Z0-9._%+-]= +@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})>\s*(?:@(?P\w+))?$") + + +class BadPerson(Exception): + "Exception for un-parsable person" + + +class Person: + "Class representing a maintainer or reviewer and their details" + + def __init__(self, info): + match =3D person_re.search(info) + + if match is None: + raise BadPerson(f"Failed to parse {info}") + + self.name =3D match.group('name') + self.email =3D match.group('email') + + def __str__(self): + return f"{self.name} <{self.email}>" + + +class MaintainerSection: + "Class representing a section of MAINTAINERS" + + def _expand(self, pattern): + if pattern.endswith("/"): + return f"{pattern}*" + return pattern + + def __init__(self, section, entries): + self.section =3D section + self.status =3D Status.UNKNOWN + self.maintainers =3D [] + self.reviewers =3D [] + self.files =3D [] + self.files_exclude =3D [] + self.trees =3D [] + self.lists =3D [] + self.web =3D [] + self.keywords =3D [] + + for e in entries: + (tag, data) =3D e.split(": ", 2) + + if tag =3D=3D "M": + person =3D Person(data) + self.maintainers.append(person) + elif tag =3D=3D "R": + person =3D Person(data) + self.reviewers.append(person) + elif tag =3D=3D "S": + self.status =3D Status(data) + elif tag =3D=3D "L": + self.lists.append(data) + elif tag =3D=3D 'F': + pat =3D self._expand(data) + self.files.append(pat) + elif tag =3D=3D 'W': + self.web.append(data) + elif tag =3D=3D 'K': + self.keywords.append(data) + elif tag =3D=3D 'T': + self.trees.append(data) + elif tag =3D=3D 'X': + pat =3D self._expand(data) + self.files_exclude.append(pat) + else: + raise UnhandledTag(f"'{tag}' is not understood.") + + + +def read_maintainers(src): + """ + Read the MAINTAINERS file, return a list of MaintainerSection objects. + """ + + mfile =3D path.join(src, 'MAINTAINERS') + entries =3D [] + + section =3D None + fields =3D [] + + with open(mfile, 'r', encoding=3D'utf-8') as f: + for line in f: + if not line.strip(): # Blank line found, potential end of a s= ection + if section: + new_section =3D MaintainerSection(section, fields) + entries.append(new_section) + # reset for next section + section =3D None + fields =3D [] + elif tag_re.match(line): + fields.append(line.strip()) + else: + if line.startswith("-") or line.startswith("=3D"): + continue + + section =3D line.strip() + + return entries =20 =20 # @@ -104,6 +254,12 @@ def main(): group.add_argument('-f', '--file', type=3Dvalid_file_path, help=3D'path to source file') =20 + # Validate MAINTAINERS + parser.add_argument('--validate', + action=3DBooleanOptionalAction, + default=3DNone, + help=3D"Just validate MAINTAINERS file") + # We need to know or be told where the root of the source tree is src =3D find_src_root() =20 @@ -112,6 +268,16 @@ def main(): =20 args =3D parser.parse_args() =20 + try: + # Now we start by reading the MAINTAINERS file + maint_sections =3D read_maintainers(args.src) + except Exception as e: + print(f"Error: {e}") + exit(-1) + + if args.validate: + print(f"loaded {len(maint_sections)} from MAINTAINERS") + exit(0) =20 =20 if __name__ =3D=3D '__main__': --=20 2.47.3