(path: str,
pattern: Union[str, List],
fuzzy: bool = False)
| 4 | |
| 5 | |
| 6 | def match_files(path: str, |
| 7 | pattern: Union[str, List], |
| 8 | fuzzy: bool = False) -> List[Tuple[str, str]]: |
| 9 | if isinstance(pattern, str): |
| 10 | pattern = [pattern] |
| 11 | if fuzzy: |
| 12 | pattern = [f'*{p}*' for p in pattern] |
| 13 | files_list = [] |
| 14 | for root, _, files in os.walk(path): |
| 15 | for name in files: |
| 16 | for p in pattern: |
| 17 | if fnmatch.fnmatch(name.lower(), p.lower()): |
| 18 | files_list.append((name[:-3], os.path.join(root, name))) |
| 19 | break |
| 20 | |
| 21 | return sorted(files_list, key=lambda x: x[0]) |
no test coverage detected