Skip to main content

No project description provided

Project description

files_finder -- Find files recursively
========================================


Introduction
------------

This package implements the `FilesFinder` class to simplify finding files
recursively from a specified directory. This class is easier to use, yet more
powerful than `os.walk`.

Examples
--------

Below is a few examples, for more ways to use `FilesFinder`, see the
samples directory.

Find all files:

from files_finder import FilesFinder
for filename in FilesFinder('.'):
print(filename)

Exclude a single pattern:

from files_finder import FilesFinder, wildcard
for filename in FilesFinder('.', exclude=wildcard('*.bak')):
print(filename)

Exclude more than one patterns:

from files_finder import FilesFinder, wildcard
for filename in FilesFinder('.', exclude=wildcard('*.bak', '*~')):
print(filename)

Only include files that match some patterns:

from files_finder import FilesFinder, wildcard
for filename in FilesFinder('.', include=wildcard('*.csv', '*.xml')):
print(filename)


FilesFinder Object
------------------

FilesFinder(root, exclude=None, include=None, recurse=True)

Creates a new `FilesFinder` object. The caller can loop
through the object to gain access to all the files found in the
`root` directory. See the Examples section.

`root` is a string representing the directory to search for files.

`exclude` is a function which takes in a path and returns a boolean
indicating if that path should be excluded from the results. The
default is None which means do not exclude any file. Note that the
`exclude` parameter has precedence over the `include` parameter.

`include` is a function which takes in a path and returns a boolean
indicating if that path should be included in the results.

`recurse` is a boolean indicating if `FilesFinder` should
search recursively. The default is True.

Project details


Release history Release notifications | RSS feed

This version

1.0

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