INNER CODE UNIT · Python

_get_valid_filepaths_by_ext_set

mfarragher/obsidiantools · obsidiantools/_io.py:87

def _get_valid_filepaths_by_ext_set(dirpath: Path, *,
                                    exts: set[str]):
    all_files = [p.relative_to(dirpath)
                 for p in Path(dirpath).glob("**/*")
                 if p.suffix in exts]
    return all_files


def _get_shortest_path_by_filename(relpaths_list: list[Path]) -> dict[str, Path]:
    # get filename w/ ext only:
    all_file_names_list = [f.name for f in relpaths_list]

    # get indices of dupe 'filename w/ ext':
    _, inverse_ix, counts = np.unique(
        np.array(all_file_names_list),
        return_inverse=True,
        return_counts=True,
        axis=0)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…