rignore

0.7.6 · active · verified Sun Apr 05

rignore is a Python module that provides high-performance, Rust-powered file system traversal functionality. It efficiently walks through directories while respecting various ignore rules, such as those found in `.gitignore` files. It wraps the Rust `ignore` crate using PyO3, offering a fast and customizable API. The current version is 0.7.6, with a relatively active release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `rignore.walk` to traverse a directory while respecting a `.gitignore` file. It creates a temporary directory structure and then prints the paths of files not ignored.

import rignore
import os

# Create a dummy directory structure for demonstration
os.makedirs('my_project/src', exist_ok=True)
os.makedirs('my_project/build', exist_ok=True)
with open('my_project/.gitignore', 'w') as f:
    f.write('*.tmp\n')
    f.write('/build/\n')
with open('my_project/src/main.py', 'w') as f: pass
with open('my_project/src/temp.tmp', 'w') as f: pass
with open('my_project/build/output.log', 'w') as f: pass

print('Files found by rignore.walk:')
for file_path in rignore.walk('my_project'):
    print(file_path)

# Clean up (optional)
import shutil
shutil.rmtree('my_project')

view raw JSON →