Skip to main content

trailrunner

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")))
[
    PosixPath('trailrunner/__init__.py'),
    PosixPath('trailrunner/__version__.py'),
    PosixPath('trailrunner/core.py'),
    PosixPath('trailrunner/tests/__init__.py'),
    PosixPath('trailrunner/tests/__main__.py'),
    PosixPath('trailrunner/tests/core.py'),
]

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/core.py'), Path('trailrunner/tests/core.py')]
>>> run(paths, str)
{
    PosixPath('trailrunner/core.py'): 'trailrunner/core.py',
    PosixPath('trailrunner/tests/core.py'): 'trailrunner/tests/core.py',
}

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/__init__.py'): 'trailrunner/tests/__init__.py',
    PosixPath('trailrunner/tests/__main__.py'): 'trailrunner/tests/__main__.py',
    PosixPath('trailrunner/tests/core.py'): 'trailrunner/tests/core.py',
}

Install

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

$ pip install trailrunner

License

trailrunner is copyright Amethyst 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.

Release files for trailrunner 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trailrunner 1.4.0
File Size Uploaded
trailrunner-1.4.0.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trailrunner 1.4.0
File Interpreter ABI Platform
trailrunner-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / trailrunner-1.4.0.tar.gz

Download URL trailrunner-1.4.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3fe61e259e6b2e5192f321c265985b7a0dc18497ced62b2da244f08104978398
BLAKE2b-256 checksum
How to use checksums
4d93630e10bacd897daeb9ff5a408f4e7cb0fc2f243e7e3ef00f9e6cf319b11c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.2

Release files / trailrunner-1.4.0-py3-none-any.whl

Download URL trailrunner-1.4.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a286d39f2723f28d167347f41cf8f232832648709366e722f55cf5545772a48e
BLAKE2b-256 checksum
How to use checksums
b12921001afea86bac5016c3940b43de3ce4786b0d8337d4ea79bb903c649ce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.2

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page