|
6 | 6 | import argparse
|
7 | 7 | from collections import defaultdict, Counter
|
8 | 8 | from dataclasses import dataclass, field
|
| 9 | +import difflib |
9 | 10 | import itertools
|
10 | 11 | from pathlib import Path
|
11 | 12 | import pykwalify.core
|
@@ -372,7 +373,9 @@ def add_args(parser):
|
372 | 373 | parser.add_argument("--board", dest='board', default=None,
|
373 | 374 | help='lookup the specific board, fail if not found')
|
374 | 375 | parser.add_argument("--board-dir", default=[], type=Path, action='append',
|
375 |
| - help='Only look for boards at the specific location') |
| 376 | + help='only look for boards at the specific location') |
| 377 | + parser.add_argument("--fuzzy-match", default=None, |
| 378 | + help='lookup boards similar to the given board name') |
376 | 379 |
|
377 | 380 |
|
378 | 381 | def add_args_formatting(parser):
|
@@ -414,6 +417,9 @@ def board_v2_qualifiers_csv(board):
|
414 | 417 |
|
415 | 418 | def dump_v2_boards(args):
|
416 | 419 | boards = find_v2_boards(args)
|
| 420 | + if args.fuzzy_match is not None: |
| 421 | + close_boards = difflib.get_close_matches(args.fuzzy_match, boards.keys()) |
| 422 | + boards = {b: boards[b] for b in close_boards} |
417 | 423 |
|
418 | 424 | for b in boards.values():
|
419 | 425 | qualifiers_list = board_v2_qualifiers(b)
|
@@ -441,6 +447,11 @@ def dump_v2_boards(args):
|
441 | 447 | def dump_boards(args):
|
442 | 448 | arch2boards = find_arch2boards(args)
|
443 | 449 | for arch, boards in arch2boards.items():
|
| 450 | + if args.fuzzy_match is not None: |
| 451 | + close_boards = difflib.get_close_matches(args.fuzzy_match, [b.name for b in boards]) |
| 452 | + if not close_boards: |
| 453 | + continue |
| 454 | + boards = [b for b in boards if b.name in close_boards] |
444 | 455 | if args.cmakeformat is None:
|
445 | 456 | print(f'{arch}:')
|
446 | 457 | for board in boards:
|
|
0 commit comments