Skip to main content

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).

Release files for yautil 0.0.69

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

Source distribution (sdist)

Source distribution for yautil 0.0.69
File Size Uploaded
yautil-0.0.69.tar.gz 38.4 kB Details

Built distribution (wheel)

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

Total release size:84.9 kB

Release files / yautil-0.0.69.tar.gz

Download URL yautil-0.0.69.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b502ff49f3d52027b592e2e4bbf3f30c019e9e1f9d6705e57431246e0937f9a3
BLAKE2b-256 checksum
How to use checksums
21fd7f64f245a87cc5c165b98b31f88e358db6fc650e7e88bbf60339b8adc05c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / yautil-0.0.69-py3-none-any.whl

Download URL yautil-0.0.69-py3-none-any.whl
Size 46.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3adb0dbbd9983a2a909ba7998d83f5429adc9bd8a4cefca4d558195bde5ee2ae
BLAKE2b-256 checksum
How to use checksums
bab918fef5aba16a715cfd33c88e0b2f8ce1fc6b45036be67d5a409a2e444113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.0.69 This release

2 release files

0.0.68

2 release files

0.0.66

2 release files

0.0.65

2 release files

0.0.62

2 release files

0.0.58

2 release files

0.0.57

2 release files

0.0.56

2 release files

0.0.55

2 release files

0.0.53

2 release files

0.0.51

2 release files

0.0.50

2 release files

0.0.49

2 release files

0.0.48

2 release files

0.0.46

2 release files

0.0.45

2 release files

0.0.44

2 release files

0.0.43

2 release files

0.0.42

2 release files

0.0.41

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.37

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.27

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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