A utility to find file paths.
frompathfinderimportfind_paths# get all directories and sub-directories in current directorypaths=find_paths(".", just_dirs=True)
# get all files in the current directory and all sub-directoriespaths=find_paths(".", just_files=True)
# get all jpg files using a regexpaths=find_paths(".", regex=".*\.jpg$")
# get all jpg files using posix wildcardspaths=find_paths(".", fnmatch="*.jpg")
# get all jpg files and png filesfrompathfinderimportFnmatchFilterfrompathfinderimportOrFilterjpg_filter=FnmatchFilter("*.jpg")
png_filter=FnmatchFilter("*.png")
gif_filter=FnmatchFilter("*.gif")
image_filter=OrFilter(jpg_filter, png_filter, gif_filter)
paths=find_paths(".", filter=image_filter)
# shortcut using bitwise orpaths=find_paths(".", filter=jpg_filter|png_filter|gif_filter)
# even shorter using ImageFilter to find all imagesfrompathfinderimportImageFilterpaths=find_paths(".", filter=ImageFilter())
# and an even shorter waypaths=ImageFilter().find(".")To install pathfinder, simply:
$ pip install pathfinderTo install development dependencies run:
$ pip install -r dev-requirements.txt