Python bindings for the Rust crate ignore
Actively maintained. Last release 6 weeks ago, commits in 5 of the last 26 weeks. A safe choice.
pip install ignore-pythonignore in Python
This is a Python library that binds to the Rust crate ignore.
ignore's Python bindings can be used for building a fast recursive
directory iterator that respects various filters such as globs, file
types and .gitignore files.
Example
This example shows the most basic usage of this package. This code
will recursively traverse the current directory while automatically
filtering out files and directories according to ignore globs found in
files like .ignore and .gitignore:
from ignore import Walk
for entry in Walk("./"):
print(entry.path())
Example: advanced
By default, the recursive directory iterator will ignore hidden files and directories. This can be disabled by building the iterator with WalkBuilder:
from ignore import WalkBuilder
for entry in WalkBuilder("./").hidden(False).build():
print(entry.path())
Refer to the API documentation for more information.
How to install
On Arch Linux
You can install the python-ignore package from the official repos:
pacman -S python-ignore
From pip
You can install the ignore-python package:
pip install ignore-python
# or
python -m pip install ignore-python
How to develop
This assumes that you have rust and cargo installed. I use the workflow recommended by pyo3 and maturin.