Friendly misc/utils/convenience library.
Project description
Friendly misc/utils/convenience library.
Overview
runez is a convenience "utils" library for common operations I found myself rewriting multiple times.
The name was initially meant as “run ez” (“run easy”), the fact that it sounds like “runes” gives it a bit of a mystery/magic side that’s also relatively appropriate (it does indeed concentrate a bit of invocation magic, as you can save quite a few lines of repetitive code by using it)
Features
Usable with any python version
Pure python standalone library, does not bring in any additional dependency
Takes care of most edge cases, with nice errors
Functions can be called without checking for return code etc (abort by default, with nice error)
They can also be called with fatal=False, in which case the return value will indicate whether call succeeded or not
Support for dryrun mode (show what would be done, but don’t do it)
Perform most typical logging setups in one call to runez.log.setup()
Log operations systematically (at debug level mostly), examples:
Running: foo ... Copy foo -> bar Would move foo -> bar (for dryrun)
CaptureOutput context manager -> grab output/logging from any code section
100% test coverage
Example
Run a program:
import runez # Aborts if "foo" doesn't exist output = runez.run("ls", "foo") # Output can also be ignored runez.run("ls", "foo") # Don't capture output, just run the command and let output "pass through" runez.run("ls", "foo", stdout=None, stderr=None) # Don't abort, return False on failure (or actual output when successful) output = runez.run("ls", "foo", fatal=False)
File operations:
import runez runez.touch("foo") runez.copy("foo", "bar") runez.move("foo", "baz") runez.delete("foo") runez.write("foo", "bar\nbaz\n") first = runez.first_line("foo") lines = runez.get_lines("foo") full_path = runez.resolved_path("foo/bar") folder = runez.parent_folder(full_path) runez.ensure_folder(folder) with runez.Anchored(folder): assert runez.short(full_path) == "bar"
Installation
As usual, available on pypi: pip install runez
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
File details
Details for the file runez-1.10.31.tar.gz
.
File metadata
- Download URL: runez-1.10.31.tar.gz
- Upload date:
- Size: 54.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4a9e4c9a7fac99f6d6df42837793aa304238c19dc2133627f99c55041bf3b53 |
|
MD5 | df9fd69b511f48b74729909a992ce870 |
|
BLAKE2b-256 | 269afa04805140e4e2b18dd961baccf2ec93590e4d000223791f90739205557d |
Provenance
File details
Details for the file runez-1.10.31-py2.py3-none-any.whl
.
File metadata
- Download URL: runez-1.10.31-py2.py3-none-any.whl
- Upload date:
- Size: 64.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd1f8ace8aec40c82fe72db72169b674c0923f9cdc0c1d81e075e185839c82e8 |
|
MD5 | eaae55d4895159366dfc04aebeb6a72a |
|
BLAKE2b-256 | 1577bbbc2142775b01f8d8f72cc814ab81f65d5c018fff0383d53d090e211175 |