Find files recursively. Args: root_dir (str): Root root_dir to find. query (str): Query to find. include_root_dir (bool): If False, root_dir name is not included. Returns: list: List of found filenames.
(root_dir, query="*.wav", include_root_dir=True)
| 15 | |
| 16 | |
| 17 | def find_files(root_dir, query="*.wav", include_root_dir=True): |
| 18 | """Find files recursively. |
| 19 | |
| 20 | Args: |
| 21 | root_dir (str): Root root_dir to find. |
| 22 | query (str): Query to find. |
| 23 | include_root_dir (bool): If False, root_dir name is not included. |
| 24 | |
| 25 | Returns: |
| 26 | list: List of found filenames. |
| 27 | |
| 28 | """ |
| 29 | files = [] |
| 30 | for root, dirnames, filenames in os.walk(root_dir, followlinks=True): |
| 31 | for filename in fnmatch.filter(filenames, query): |
| 32 | files.append(os.path.join(root, filename)) |
| 33 | if not include_root_dir: |
| 34 | files = [file_.replace(root_dir + "/", "") for file_ in files] |
| 35 | |
| 36 | return files |
| 37 | |
| 38 | |
| 39 | def read_hdf5(hdf5_name, hdf5_path): |
nothing calls this directly
no outgoing calls
no test coverage detected