pathsummary.PathSummary.iter_by_filetype
- PathSummary.iter_by_filetype(file_type: str, sub_type: Optional[str] = None) pathlib.Path
Iterates the filepaths releated to the file type and optionally sub type.
- Parameters
file_type – Files based on the file type are yielded.
sub_type – Optional sub type to narrow the selection down.
- Returns
Path
Examples
>>> from pathsummary import summarize_folder_files, FileTypes >>> from doctestprinter import print_pandas, doctest_iter_print >>> from pathlib import Path >>> test_file_paths = [ ... Path("tests/resources/images/image01.BMP"), ... Path("tests/resources/images/image00.jpeg"), ... Path("tests/resources/images/image00.jpg"), ... Path("tests/resources/images/image01.JPEG"), ... Path("tests/resources/images/image01.JPG"), ... ] >>> sample_summary = PathSummary.from_file_paths(test_file_paths) >>> doctest_iter_print(sample_summary.iter_by_filetype(FileTypes.IMAGE)) tests/resources/images/image01.BMP tests/resources/images/image00.jpeg tests/resources/images/image00.jpg tests/resources/images/image01.JPEG tests/resources/images/image01.JPG
>>> doctest_iter_print( ... sample_summary.iter_by_filetype(FileTypes.IMAGE, "bmp") ... ) tests/resources/images/image01.BMP
>>> test_file_paths = [Path("a/path/text.csv")] >>> sample_summary = PathSummary.from_file_paths(test_file_paths) >>> doctest_iter_print(sample_summary.iter_by_filetype("text", "csv")) a/path/text.csv