Skip to main content

Run things on paths

Project description

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

Uploaded Source

Built Distribution

trailrunner-1.1.3-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file trailrunner-1.1.3.tar.gz.

File metadata

  • Download URL: trailrunner-1.1.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for trailrunner-1.1.3.tar.gz
Algorithm Hash digest
SHA256 ceb22d0c6e6439a72d4d94585aae2599107f6f9cf28c102cb7643a958f8b9bb7
MD5 d30edd6327a4771ae67e901eb7e5d067
BLAKE2b-256 0c3231b3060b01b37fed1cdd6c155174f75d0a5c7ec2bb91311327db1f4e8ac8

See more details on using hashes here.

File details

Details for the file trailrunner-1.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for trailrunner-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7eea60167384329012a5b5464b4e97da68e8984fa52286094c08dbe9fce8901d
MD5 d089e1ff040b118170be7fe3f4c6a620
BLAKE2b-256 53a3df20af7c815299e2782862375121051a6403ad4cb6a3c8116f3443f2124b

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