Run things on paths
Project description
trailrunner
Walk paths and run things
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for trailrunner-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ebfe31c3c7ce5dcc332c09ee802c99d397a03f53a6401f70a0c5ac79e55ec37 |
|
MD5 | 33f7982c9c35aad219797e929669f6d1 |
|
BLAKE2b-256 | 5a508ee99eb9ced28dd2d6b50604acfdbffc1192db8fc48718525f760c845a9a |