Skip to main content

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:

  1. trigger callback on each matched file / directory
def callback(name, path):
    print(path)

find("path/to/dir").for_each(callback)
  1. 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

https://github.com/mugiseyebrows/pyfindlib

Project details


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)

Uploaded Source

Built Distribution

minifind-0.0.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page