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

.mtime(low, high) - match modification time

.filter(predicate) - match with your predicate

.maxdepth(n) - don't go deeper than n levels in.

.first(n) - stop after n matched files

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.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

minifind-0.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file minifind-0.0.3.tar.gz.

File metadata

  • Download URL: minifind-0.0.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for minifind-0.0.3.tar.gz
Algorithm Hash digest
SHA256 de20a9b19ce011a9754bca771ce08ac066b38e511cdad2fd7e178e7a2fa5ad93
MD5 99c54595d5fac467023c81eebfbdf204
BLAKE2b-256 2a716488c8ae09e087889973cf0b067a00a2ede13725e82da0777dd4caa57b8d

See more details on using hashes here.

File details

Details for the file minifind-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: minifind-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for minifind-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 20d2e971b5f4e0effea15d62091d81ce32edda4ecd9ede0b7af8b4b0289c4a32
MD5 bf7fb7056f444c1fb946d84bd77fbdc2
BLAKE2b-256 e688a119e09ed7ec68767b1d5e869de02378f3235419a232d7f3ba0018d9371f

See more details on using hashes here.

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