/crabwalk

Fast recursive directory iterator which supports .gitignore files, file types, and glob filtering.

Primary LanguageRustOtherNOASSERTION

PyPI Documentation CI Status MIT License

crabwalk

crabwalk is a Python package built in Rust on top of the excellent ignore crate:

The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files.

Examples

Defaults

By default, Walk will recursively traverse the given path(s) while ignoring hidden files and those matching globs found in .gitignore and .ignore files:

from crabwalk import Walk

with Walk(".") as walk:
    for entry in walk:
        print(entry.path)

Disable standard filters

To disable all default filtering (and therefore behave more like os.walk), you can set the corresponding flags individually or use the helper method shown here:

from crabwalk import Walk

with Walk(".") as walk:
    walk.disable_standard_filters()
    for entry in walk:
        print(entry.path)

Advanced

Disable the hidden files filter and enable parsing of custom ignore files called .myignore:

from crabwalk import Walk

with Walk(".", hidden=False, custom_ignore_filenames=(".myignore",)) as walk:
    for entry in walk:
        print(entry.path)

See the documentation for all options.