Skip to content

Commit

Permalink
BaseTools/Scripts/GetMaintainer: refactor internal returns as dicts
Browse files Browse the repository at this point in the history
To clean up interfaces, change the lookup functions to return dictionaries
rather than multiple values.

Cc: Rebecca Cran <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Bob Feng <[email protected]>
Cc: Yuwei Chen <[email protected]>
Cc: Michael D Kinney <[email protected]>
Signed-off-by: Leif Lindholm <[email protected]>
Acked-by: Rebecca Cran <[email protected]>
Reviewed-by: Michael D Kinney <[email protected]>
  • Loading branch information
leiflindholm authored and mergify[bot] committed Nov 11, 2023
1 parent 1cb580b commit 05f3c3f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions BaseTools/Scripts/GetMaintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,32 @@ def get_section_maintainers(path, section):
else:
lists += [address]

return maintainers, lists
return {'maintainers': maintainers, 'lists': lists}

def get_maintainers(path, sections, level=0):
"""For 'path', iterates over all sections, returning maintainers
for matching ones."""
maintainers = []
lists = []
for section in sections:
tmp_maint, tmp_lists = get_section_maintainers(path, section)
maintainers += tmp_maint
lists += tmp_lists
recipients = get_section_maintainers(path, section)
maintainers += recipients['maintainers']
lists += recipients['lists']

if not maintainers:
# If no match found, look for match for (nonexistent) file
# REPO.working_dir/<default>
print('"%s": no maintainers found, looking for default' % path)
if level == 0:
maintainers = get_maintainers('<default>', sections, level=level + 1)
recipients = get_maintainers('<default>', sections, level=level + 1)
maintainers += recipients['maintainers']
lists += recipients['lists']
else:
print("No <default> maintainers set for project.")
if not maintainers:
return None

return maintainers + lists
return {'maintainers': maintainers, 'lists': lists}

def parse_maintainers_line(line):
"""Parse one line of Maintainers.txt, returning any match group and its key."""
Expand Down Expand Up @@ -184,9 +186,8 @@ def get_modified_files(repo, args):

for file in FILES:
print(file)
addresslist = get_maintainers(file, SECTIONS)
if addresslist:
ADDRESSES += addresslist
recipients = get_maintainers(file, SECTIONS)
ADDRESSES += recipients['maintainers'] + recipients['lists']

for address in list(OrderedDict.fromkeys(ADDRESSES)):
if '<' in address and '>' in address:
Expand Down

0 comments on commit 05f3c3f

Please sign in to comment.