Skip to main content

Run things on paths

Project description


Walk paths and run things

version documentation changelog license build status code coverage

trailrunner is a simple library for walking paths on the filesystem, and executing functions for each file found. trailrunner obeys project level .gitignore files, and runs functions on a process pool for increased performance. trailrunner is designed for use by linting, formatting, and other developer tools that need to find and operate on all files in project in a predictable fashion with a minimal API:

walk() takes a single Path, and generates a list of significant files in that tree:

>>> from trailrunner import walk
>>> sorted(walk(Path("trailrunner")))

run() takes a list of Path objects and a function, and runs that function once for each path given. It runs these functions on a process pool, and returns a mapping of paths to results:

>>> from trailrunner import run
>>> paths = [Path('trailrunner/'), Path('trailrunner/tests/')]
>>> run(paths, str)
    PosixPath('trailrunner/'): 'trailrunner/',
    PosixPath('trailrunner/tests/'): 'trailrunner/tests/',

walk_and_run() does exactly what you would expect:

>>> from trailrunner import walk_and_run
>>> walk_and_run([Path('trailrunner/tests')], str)
    PosixPath('trailrunner/tests/'): 'trailrunner/tests/',
    PosixPath('trailrunner/tests/'): 'trailrunner/tests/',
    PosixPath('trailrunner/tests/'): 'trailrunner/tests/',


trailrunner requires Python 3.6 or newer. You can install it from PyPI:

$ pip install trailrunner


trailrunner is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

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

trailrunner-1.2.1.tar.gz (14.4 kB view hashes)

Uploaded source

Built Distribution

trailrunner-1.2.1-py3-none-any.whl (10.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page