os.walk wrapper with predicates
Project description
minifind
minifind is os.walk wrapper with predicates
Install
pip install minifind
Use
from minifind import find, size_kb
Find have two modes of operation:
- trigger callback on each matched file / directory
def callback(name, path):
print(path)
find("path/to/dir").for_each(callback)
- collect matched items
paths = find("path/to/dir").collect()
Examples
Find source files of size 5kb+:
def not_moc(name, path):
return not name.startswith('moc_')
paths = find("D:\\dev").ext(".cpp", ".h").filter(not_moc).size(size_kb(5)).collect()
Find git dirs, but dont go deeper that two directories in:
paths = find("D:\\dev").maxdepth(2).name('.git').collect()
Predicates and modifiers
.files() - match files
.dirs() - match dirs
.ext(*patterns) - match file extensions
.name(*patterns) - match name patterns
.size(low, high) - match file size
.filter(predicate) - match with your predicate
.maxdepth(n) - dont go deeper than n levels in.
See also
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
minifind-0.0.2.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file minifind-0.0.2.tar.gz
.
File metadata
- Download URL: minifind-0.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 879db4a4dc19a710ead84132c3cf092224152604e19dda2b186730f8faf4d759 |
|
MD5 | cf8c2b1631044d6d7627b17244f84456 |
|
BLAKE2b-256 | ea4c900e9c7d2ffbcb6a185c68d1500e940271f8240335e9977c238ef99265e8 |
File details
Details for the file minifind-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: minifind-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2588639d43e6e876a0eee32f23e3208f3126bdfcc88fe3334ebda9a0482bee |
|
MD5 | 80d4f5b4c2405592e2bce0b81252a54c |
|
BLAKE2b-256 | 8f5dcbdbd9a18805210e565c15b179b40ce440fc02c7cd42087efdf318fcc738 |