ignore-python

raw JSON →
0.3.3 verified Mon Apr 27 auth: no python

Python bindings for the Rust `ignore` crate, providing fast, parallel filesystem traversal with gitignore-style pattern matching. Currently at version 0.3.3, released periodically. Supports Python >=3.8.

pip install ignore-python
error ImportError: cannot import name 'GitIgnore' from 'ignore'
cause The class is called `Ignore`, not `GitIgnore`.
fix
Use from ignore import Ignore.
error TypeError: Ignore() takes 1 positional argument but 2 were given
cause The constructor signature changed in 0.3.0; `patterns` must be passed as a keyword argument.
fix
Use Ignore(patterns=['*.pyc']) instead of Ignore(['*.pyc']).
error AttributeError: module 'ignore' has no attribute 'Walk'
cause `import ignore` gives the top-level module, not the Rust bindings.
fix
Use from ignore import Walk.
gotcha The `Walk` iterator yields `Path` objects relative to the root, not absolute paths.
fix Use `path.resolve()` or join with root if absolute paths are needed.
gotcha Default behavior excludes hidden files (those starting with '.') unless `hidden=False` is passed.
fix Pass `hidden=True` to include hidden files.
deprecated The `Ignore` class constructor changed between 0.2.x and 0.3.x; now requires a `patterns` argument of type `List[str]`.
fix Use `Ignore(patterns=['*.pyc', '__pycache__/'])` instead of `Ignore(match=['*.pyc'])`.
breaking In version 0.3.0, the `Walk` class removed the `gitignore` parameter (use `produce_gitignore` instead).
fix Replace `Walk(path, gitignore=True)` with `Walk(path, produce_gitignore=True)`.

Walks the ./src directory, respecting .gitignore rules.

from ignore import Walk

walker = Walk('./src', produce_gitignore=True)
for path in walker:
    print(path)