Yet Another Python util.
Project description
yautil
Yet Another Python util — a grab bag of helpers grown out of day-to-day work: argparse extensions, file utilities, multiprocessing-friendly caches, Docker shell helpers, plotting wrappers, password/keyring helpers, and a transactional filesystem-mount API.
Failed sub-imports degrade to dummy modules (so import yautil works even if one optional dep is missing). Python ≥ 3.11.
Install
pip install -e .
Requires sh, matplotlib; optional: argcomplete, keyring, tqdm.
API
Top-level re-exports — from yautil import ...:
argparse extensions (yautil.argparse)
| Symbol | Purpose |
|---|---|
OverridingAppendAction |
append-style action where a later flag replaces the accumulated list. |
SplitAppendAction |
append that splits each value on a delimiter (e.g. a,b,c). |
SmartAppendAction |
Heuristic combination of override + split semantics. |
ChoiceComb |
list[str] subclass used as choices= to allow comma-separated combinations. |
WarningAction |
--warning=foo,bar action with allowed-value validation. |
Files (yautil.file)
| Symbol | Purpose |
|---|---|
find(root, ...) |
Non-recursive find with name patterns / type filter. |
find_recursive(root, name_patterns=None, ignored_dirs=None, type='any', depth=-1, sort=False) |
Recursive find with prune list. |
remove_contents(folder) |
Delete every entry inside folder without removing it. |
overwrite(src, dst) |
Replace dst with src atomically. |
get_memtmpdir(suffix=None, prefix=None, dir=None) |
TemporaryDirectory on /dev/shm (or tmpfs) when available. |
Writable |
File-like wrapper that proxies writes; useful for piping output. |
Decorators (yautil.decorators)
| Symbol | Purpose |
|---|---|
static_vars(**kw) |
Attach mutable "static" attributes to a function on first call. |
Events (yautil.event)
| Symbol | Purpose |
|---|---|
Event |
Listenable event object (+= handler to subscribe, call to fire). |
EventGenerator |
Mixin / factory that declares named Events on an object. |
Printing (yautil.print)
| Symbol | Purpose |
|---|---|
decomment_cxx(text) |
Strip // and /* */ comments from C/C++/Java text. |
auto_print(string, max_len=-1, **kwargs) |
print with auto-truncation past max_len. |
strcompare(left, right, width=-1, highlight=True) -> str |
Side-by-side diff string with ANSI highlighting. |
Plotting (yautil.plot)
Thin matplotlib wrappers — all accept *data and a common set of styling kwargs.
| Symbol | Plot type |
|---|---|
plot_cdf |
Cumulative distribution function. |
plot_linear |
Line plot. |
plot_scatter |
Scatter plot. |
plot_box |
Box plot. |
plot_stack |
Stacked area / bar plot. |
Caches
| Symbol | Purpose |
|---|---|
lru_cache(...) (yautil.lru_cache_ext) |
Like functools.lru_cache but hashes list/dict arguments too. |
PersistentCache (yautil.persistent_cache) |
Disk-backed cache under ~/.cache/; survives process restarts. |
Passwords (yautil.passwd)
| Symbol | Purpose |
|---|---|
create_w_password(...) |
Build an object that requires interactive password unlock. |
create_w_secrets(...) |
Build an object that pulls secrets from a password-protected store. |
(See the module for the exact constructor signatures — both wrap keyring and an encrypted local secrets file.)
Docker shell (yautil.docker_sh)
| Symbol | Purpose |
|---|---|
docker_sh(...) |
sh-compatible Command that runs inside a built/pulled Docker image, with bind mounts, user-id pass-through, and interactive TTY support. |
AuthorizationError |
Raised when the daemon refuses (e.g. missing docker login). |
Git (yautil.git)
| Symbol | Purpose |
|---|---|
git_expand(repo, dest, *checkout_targets, ignore_errors=False, iter=False) |
Shallow-clone (or update) repo into dest for each checkout_target (branch/tag/sha). |
git_merge_file(...) |
Three-way file merge wrapping git merge-file. |
IO (yautil.io)
| Symbol | Purpose |
|---|---|
FilteredTextIO |
TextIO proxy that runs every write through a WriteCallback. |
Shell interop (yautil.pysh)
| Symbol | Purpose |
|---|---|
compile_shargs(*args, **kwargs) |
Pack Python call args into the (args, kwargs) form sh.Command expects. |
get_cmd_args(cmd) |
Recover the argv that produced a given sh.Command invocation. |
Mount API (yautil.mount)
Filesystem-mount abstraction for disk images / archives, plus high-level mount / extract / archive helpers.
from yautil.mount import mount, extract, archive, DiskImage, LinuxDiskImage
| Symbol | Purpose |
|---|---|
mount(target) |
Context manager that mounts target and yields the mount point. |
extract(target, dest) |
Extract contents of target into dest. |
archive(src, dest, type) |
Build an archive of src at dest. |
Mountable |
Base class for anything that can be mounted (loop devices, archives). |
Archive |
Mountable subclass for archive formats. |
MountableType, ArchiveType |
Enums of supported types. |
DiskImage, LinuxDiskImage |
Concrete Mountable for raw/Linux disk images (uses udisksctl). |
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yautil-0.0.69.tar.gz.
File metadata
- Download URL: yautil-0.0.69.tar.gz
- Upload date:
- Size: 38.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b502ff49f3d52027b592e2e4bbf3f30c019e9e1f9d6705e57431246e0937f9a3
|
|
| MD5 |
be1dcd5879ce2afcf7221b0feff1854e
|
|
| BLAKE2b-256 |
21fd7f64f245a87cc5c165b98b31f88e358db6fc650e7e88bbf60339b8adc05c
|
File details
Details for the file yautil-0.0.69-py3-none-any.whl.
File metadata
- Download URL: yautil-0.0.69-py3-none-any.whl
- Upload date:
- Size: 46.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3adb0dbbd9983a2a909ba7998d83f5429adc9bd8a4cefca4d558195bde5ee2ae
|
|
| MD5 |
6ee38ab9bc9abbfb8c355714705f2618
|
|
| BLAKE2b-256 |
bab918fef5aba16a715cfd33c88e0b2f8ce1fc6b45036be67d5a409a2e444113
|