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.1.tar.gz
(3.5 kB
view hashes)