From nobody Sun Feb 8 19:39:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+77571+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77571+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1625715984; cv=none; d=zohomail.com; s=zohoarc; b=cQ2WpAtXw/02Ooi9yldgFm64b/trOeNRf/FfYn5k4YVEydKzJdBKmoZUacnLQNjzmOOw5Sjbn51fPJ3LRBZNFKMSad2rU1uYf/1RYSEM8RgRhVhMNoZ4o94CAO3/eZQM7bThAOV7HVS6ygURJ/fNFBgLIKR317+5CcNIrQ8BOvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625715984; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yp9P9acOBxFUAd80jHmZo8RGWEapRz5vbBnrGELkMto=; b=luDtRjagQ2MqpJacjyhDnEKX9ZFcFZsuVY+trzfSZcRB3bAB45ACC5GCFXyw8xq/MeIVdlFgx2qMYFHv0U7liAK0HA+GB401DDQIYx+3yKWHK+LcokkTTCN4E5YWrG4iqX/VSD4I3XZNvzUc/S1cPZ98d2sMBUHunOewWD0kNso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77571+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1625715984975703.5936652019745; Wed, 7 Jul 2021 20:46:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XMMGYY1788612xayDzwEscQ9; Wed, 07 Jul 2021 20:46:24 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.7556.1625715982744589986 for ; Wed, 07 Jul 2021 20:46:23 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10038"; a="209477855" X-IronPort-AV: E=Sophos;i="5.84,222,1620716400"; d="scan'208";a="209477855" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2021 20:46:20 -0700 X-IronPort-AV: E=Sophos;i="5.84,222,1620716400"; d="scan'208";a="411198035" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.48.134]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2021 20:46:20 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yuwei Chen Subject: [edk2-devel] [Patch 1/3] BaseTools/Scripts: Fix GetMaintainer.py line endings Date: Wed, 7 Jul 2021 20:46:07 -0700 Message-Id: <20210708034609.157-2-michael.d.kinney@intel.com> In-Reply-To: <20210708034609.157-1-michael.d.kinney@intel.com> References: <20210708034609.157-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: vMwyImMgwWVm1MdgJXtc9YT1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1625715984; bh=GPnexTMvT0JULF8f2p5/2ll27dNoArKoK/sBJWb1BXM=; h=Cc:Date:From:Reply-To:Subject:To; b=KW34nuW8AFf1gqtvYmb3JPLOgdi8SNMlAj9EJ+9KOON8yeq+Olgpobq05GAupdmkyrq HAKLE0P1KsgHp+1xxjVTWJDPZrcj4Pr3Zks8tLQXgpp5oPnYdBD2vHZdQ13TqfzUQXMT0 5jHwCLnpamu7Ww0iHQ7JKk+A4PfhTCokgpM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1625716888166100001 Content-Type: text/plain; charset="utf-8" Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Michael D Kinney --- BaseTools/Scripts/GetMaintainer.py | 380 ++++++++++++++--------------- 1 file changed, 190 insertions(+), 190 deletions(-) diff --git a/BaseTools/Scripts/GetMaintainer.py b/BaseTools/Scripts/GetMain= tainer.py index ed7bc7dc2b88..5ec851554d64 100644 --- a/BaseTools/Scripts/GetMaintainer.py +++ b/BaseTools/Scripts/GetMaintainer.py @@ -1,194 +1,194 @@ -## @file -# Retrieves the people to request review from on submission of a commit. -# -# Copyright (c) 2019, Linaro Ltd. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# - -from __future__ import print_function -from collections import defaultdict -from collections import OrderedDict -import argparse -import os -import re -import SetupGit - -EXPRESSIONS =3D { - 'exclude': re.compile(r'^X:\s*(?P.*?)\r*$'), - 'file': re.compile(r'^F:\s*(?P.*?)\r*$'), - 'list': re.compile(r'^L:\s*(?P.*?)\r*$'), - 'maintainer': re.compile(r'^M:\s*(?P.*<.*?>)\r*$'), - 'reviewer': re.compile(r'^R:\s*(?P.*?)\r*$'), - 'status': re.compile(r'^S:\s*(?P.*?)\r*$'), - 'tree': re.compile(r'^T:\s*(?P.*?)\r*$'), - 'webpage': re.compile(r'^W:\s*(?P.*?)\r*$') -} - -def printsection(section): - """Prints out the dictionary describing a Maintainers.txt section.""" - print('=3D=3D=3D') - for key in section.keys(): - print("Key: %s" % key) - for item in section[key]: - print(' %s' % item) - -def pattern_to_regex(pattern): - """Takes a string containing regular UNIX path wildcards - and returns a string suitable for matching with regex.""" - - pattern =3D pattern.replace('.', r'\.') - pattern =3D pattern.replace('?', r'.') - pattern =3D pattern.replace('*', r'.*') - - if pattern.endswith('/'): - pattern +=3D r'.*' - elif pattern.endswith('.*'): - pattern =3D pattern[:-2] - pattern +=3D r'(?!.*?/.*?)' - - return pattern - -def path_in_section(path, section): - """Returns True of False indicating whether the path is covered by - the current section.""" - if not 'file' in section: - return False - - for pattern in section['file']: - regex =3D pattern_to_regex(pattern) - - match =3D re.match(regex, path) - if match: - # Check if there is an exclude pattern that applies - for pattern in section['exclude']: - regex =3D pattern_to_regex(pattern) - - match =3D re.match(regex, path) - if match: - return False - - return True - - return False - -def get_section_maintainers(path, section): - """Returns a list with email addresses to any M: and R: entries - matching the provided path in the provided section.""" - maintainers =3D [] - lists =3D [] +## @file +# Retrieves the people to request review from on submission of a commit. +# +# Copyright (c) 2019, Linaro Ltd. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +from __future__ import print_function +from collections import defaultdict +from collections import OrderedDict +import argparse +import os +import re +import SetupGit + +EXPRESSIONS =3D { + 'exclude': re.compile(r'^X:\s*(?P.*?)\r*$'), + 'file': re.compile(r'^F:\s*(?P.*?)\r*$'), + 'list': re.compile(r'^L:\s*(?P.*?)\r*$'), + 'maintainer': re.compile(r'^M:\s*(?P.*<.*?>)\r*$'), + 'reviewer': re.compile(r'^R:\s*(?P.*?)\r*$'), + 'status': re.compile(r'^S:\s*(?P.*?)\r*$'), + 'tree': re.compile(r'^T:\s*(?P.*?)\r*$'), + 'webpage': re.compile(r'^W:\s*(?P.*?)\r*$') +} + +def printsection(section): + """Prints out the dictionary describing a Maintainers.txt section.""" + print('=3D=3D=3D') + for key in section.keys(): + print("Key: %s" % key) + for item in section[key]: + print(' %s' % item) + +def pattern_to_regex(pattern): + """Takes a string containing regular UNIX path wildcards + and returns a string suitable for matching with regex.""" + + pattern =3D pattern.replace('.', r'\.') + pattern =3D pattern.replace('?', r'.') + pattern =3D pattern.replace('*', r'.*') + + if pattern.endswith('/'): + pattern +=3D r'.*' + elif pattern.endswith('.*'): + pattern =3D pattern[:-2] + pattern +=3D r'(?!.*?/.*?)' + + return pattern + +def path_in_section(path, section): + """Returns True of False indicating whether the path is covered by + the current section.""" + if not 'file' in section: + return False + + for pattern in section['file']: + regex =3D pattern_to_regex(pattern) + + match =3D re.match(regex, path) + if match: + # Check if there is an exclude pattern that applies + for pattern in section['exclude']: + regex =3D pattern_to_regex(pattern) + + match =3D re.match(regex, path) + if match: + return False + + return True + + return False + +def get_section_maintainers(path, section): + """Returns a list with email addresses to any M: and R: entries + matching the provided path in the provided section.""" + maintainers =3D [] + lists =3D [] nowarn_status =3D ['Supported', 'Maintained'] - - if path_in_section(path, section): + + if path_in_section(path, section): for status in section['status']: if status not in nowarn_status: print('WARNING: Maintained status for "%s" is \'%s\'!' % (= path, status)) - for address in section['maintainer'], section['reviewer']: - # Convert to list if necessary - if isinstance(address, list): - maintainers +=3D address - else: - lists +=3D [address] - for address in section['list']: - # Convert to list if necessary - if isinstance(address, list): - lists +=3D address - else: - lists +=3D [address] - - return maintainers, lists - -def get_maintainers(path, sections, level=3D0): - """For 'path', iterates over all sections, returning maintainers - for matching ones.""" - maintainers =3D [] - lists =3D [] - for section in sections: - tmp_maint, tmp_lists =3D get_section_maintainers(path, section) - if tmp_maint: - maintainers +=3D tmp_maint - if tmp_lists: - lists +=3D tmp_lists - - if not maintainers: - # If no match found, look for match for (nonexistent) file - # REPO.working_dir/ - print('"%s": no maintainers found, looking for default' % path) - if level =3D=3D 0: - maintainers =3D get_maintainers('', sections, level= =3Dlevel + 1) - else: - print("No maintainers set for project.") - if not maintainers: - return None - - return maintainers + lists - -def parse_maintainers_line(line): - """Parse one line of Maintainers.txt, returning any match group and it= s key.""" - for key, expression in EXPRESSIONS.items(): - match =3D expression.match(line) - if match: - return key, match.group(key) - return None, None - -def parse_maintainers_file(filename): - """Parse the Maintainers.txt from top-level of repo and - return a list containing dictionaries of all sections.""" - with open(filename, 'r') as text: - line =3D text.readline() - sectionlist =3D [] - section =3D defaultdict(list) - while line: - key, value =3D parse_maintainers_line(line) - if key and value: - section[key].append(value) - - line =3D text.readline() - # If end of section (end of file, or non-tag line encountered)= ... - if not key or not value or not line: - # ...if non-empty, append section to list. - if section: - sectionlist.append(section.copy()) - section.clear() - - return sectionlist - -def get_modified_files(repo, args): - """Returns a list of the files modified by the commit specified in 'ar= gs'.""" - commit =3D repo.commit(args.commit) - return commit.stats.files - -if __name__ =3D=3D '__main__': - PARSER =3D argparse.ArgumentParser( - description=3D'Retrieves information on who to cc for review on a = given commit') - PARSER.add_argument('commit', - action=3D"store", - help=3D'git revision to examine (default: HEAD)', - nargs=3D'?', - default=3D'HEAD') - PARSER.add_argument('-l', '--lookup', - help=3D'Find section matches for path LOOKUP', - required=3DFalse) - ARGS =3D PARSER.parse_args() - - REPO =3D SetupGit.locate_repo() - - CONFIG_FILE =3D os.path.join(REPO.working_dir, 'Maintainers.txt') - - SECTIONS =3D parse_maintainers_file(CONFIG_FILE) - - if ARGS.lookup: - FILES =3D [ARGS.lookup] - else: - FILES =3D get_modified_files(REPO, ARGS) - - ADDRESSES =3D [] - - for file in FILES: - print(file) - addresslist =3D get_maintainers(file, SECTIONS) - if addresslist: - ADDRESSES +=3D addresslist - - for address in list(OrderedDict.fromkeys(ADDRESSES)): - print(' %s' % address) + for address in section['maintainer'], section['reviewer']: + # Convert to list if necessary + if isinstance(address, list): + maintainers +=3D address + else: + lists +=3D [address] + for address in section['list']: + # Convert to list if necessary + if isinstance(address, list): + lists +=3D address + else: + lists +=3D [address] + + return maintainers, lists + +def get_maintainers(path, sections, level=3D0): + """For 'path', iterates over all sections, returning maintainers + for matching ones.""" + maintainers =3D [] + lists =3D [] + for section in sections: + tmp_maint, tmp_lists =3D get_section_maintainers(path, section) + if tmp_maint: + maintainers +=3D tmp_maint + if tmp_lists: + lists +=3D tmp_lists + + if not maintainers: + # If no match found, look for match for (nonexistent) file + # REPO.working_dir/ + print('"%s": no maintainers found, looking for default' % path) + if level =3D=3D 0: + maintainers =3D get_maintainers('', sections, level= =3Dlevel + 1) + else: + print("No maintainers set for project.") + if not maintainers: + return None + + return maintainers + lists + +def parse_maintainers_line(line): + """Parse one line of Maintainers.txt, returning any match group and it= s key.""" + for key, expression in EXPRESSIONS.items(): + match =3D expression.match(line) + if match: + return key, match.group(key) + return None, None + +def parse_maintainers_file(filename): + """Parse the Maintainers.txt from top-level of repo and + return a list containing dictionaries of all sections.""" + with open(filename, 'r') as text: + line =3D text.readline() + sectionlist =3D [] + section =3D defaultdict(list) + while line: + key, value =3D parse_maintainers_line(line) + if key and value: + section[key].append(value) + + line =3D text.readline() + # If end of section (end of file, or non-tag line encountered)= ... + if not key or not value or not line: + # ...if non-empty, append section to list. + if section: + sectionlist.append(section.copy()) + section.clear() + + return sectionlist + +def get_modified_files(repo, args): + """Returns a list of the files modified by the commit specified in 'ar= gs'.""" + commit =3D repo.commit(args.commit) + return commit.stats.files + +if __name__ =3D=3D '__main__': + PARSER =3D argparse.ArgumentParser( + description=3D'Retrieves information on who to cc for review on a = given commit') + PARSER.add_argument('commit', + action=3D"store", + help=3D'git revision to examine (default: HEAD)', + nargs=3D'?', + default=3D'HEAD') + PARSER.add_argument('-l', '--lookup', + help=3D'Find section matches for path LOOKUP', + required=3DFalse) + ARGS =3D PARSER.parse_args() + + REPO =3D SetupGit.locate_repo() + + CONFIG_FILE =3D os.path.join(REPO.working_dir, 'Maintainers.txt') + + SECTIONS =3D parse_maintainers_file(CONFIG_FILE) + + if ARGS.lookup: + FILES =3D [ARGS.lookup] + else: + FILES =3D get_modified_files(REPO, ARGS) + + ADDRESSES =3D [] + + for file in FILES: + print(file) + addresslist =3D get_maintainers(file, SECTIONS) + if addresslist: + ADDRESSES +=3D addresslist + + for address in list(OrderedDict.fromkeys(ADDRESSES)): + print(' %s' % address) --=20 2.32.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#77571): https://edk2.groups.io/g/devel/message/77571 Mute This Topic: https://groups.io/mt/84061100/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-