MCPcopy Create free account
hub / github.com/InternScience/SciReason / match_files

Function match_files

opencompass/utils/file.py:6–21  ·  view source on GitHub ↗
(path: str,
                pattern: Union[str, List],
                fuzzy: bool = False)

Source from the content-addressed store, hash-verified

4
5
6def 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])

Callers 2

mainFunction · 0.90
_mf_with_multi_workdirsFunction · 0.90

Calls 1

lowerMethod · 0.45

Tested by

no test coverage detected