Skip to content

Commit 1baf81c

Browse files
committed
scripts/get_maintainer.py: find area by name
Find an area by name. Signed-off-by: Anas Nashif <[email protected]>
1 parent 171ed89 commit 1baf81c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/get_maintainer.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ def _parse_args():
109109
nargs="?",
110110
help="List all areas maintained by maintainer.")
111111

112+
113+
area_parser = subparsers.add_parser(
114+
"area",
115+
help="List area(s) by name")
116+
area_parser.add_argument(
117+
"name",
118+
metavar="AREA",
119+
nargs="?",
120+
help="List all areas with the given name.")
121+
122+
area_parser.set_defaults(cmd_fn=Maintainers._area_cmd)
123+
112124
# New arguments for filtering
113125
areas_parser.add_argument(
114126
"--without-maintainers",
@@ -220,6 +232,12 @@ def __init__(self, filename=None):
220232

221233
self.areas[area_name] = area
222234

235+
def name2areas(self, name):
236+
"""
237+
Returns a list of Area instances for the areas that match 'name'.
238+
"""
239+
return [area for area in self.areas.values() if area.name == name]
240+
223241
def path2areas(self, path):
224242
"""
225243
Returns a list of Area instances for the areas that contain 'path',
@@ -262,6 +280,14 @@ def __repr__(self):
262280
# Command-line subcommands
263281
#
264282

283+
def _area_cmd(self, args):
284+
# 'area' subcommand implementation
285+
286+
res = set()
287+
areas = self.name2areas(args.name)
288+
res.update(areas)
289+
_print_areas(res)
290+
265291
def _path_cmd(self, args):
266292
# 'path' subcommand implementation
267293

0 commit comments

Comments
 (0)