A small collection of lightweight, opinionated utilities for printing fancy console output in Python: colored strings, pretty messages, simple progress bars, task context managers, and tiny system/status helpers.
Project description
oakley
A small collection of lightweight, opinionated utilities for printing "fancy" console output in Python: colored strings, pretty messages, simple progress bars, task context managers, and tiny system/status helpers.
This package is designed for developer convenience when running short scripts or CLI-style tasks. It provides a few cooperating classes that make it easy to print colored, indented, and optionally muted output, plus a couple of helpers for memory and time display.
Features
- Colored strings with convenient format specifiers (
cstr) — easy ANSI coloring and simple format shortcuts. Messageclass for categorized, pretty messages (info, warning, error, success).Taskcontext manager to wrap and time operations, with neat completion/abort output.ProgressBariterator wrapper with estimated remaining time and non-intrusive whisper messages.MutableClassbase with global mute/tab behavior so multiple components coordinate console output.- Small status helpers:
MemoryViewandDateTimefor quick runtime info.
Installation
You can downlaod the package with this command:
pip install oakley
Alternatively, you can download the most up-to-date version from my github repository:
pip install git+https://github.com/ProfesseurShadoko/oakley.git
Quick examples
Colored strings
from oakley import cstr
print(cstr('hello world').green().bold())
print(f"Progress: {cstr('ok'):g}") # short color spec
print(f"{cstr('Done'):gb}") # in green and bold
Pretty messages
from oakley import Message
Message("Build succeeded", "#") # green success prefix
Message("Something might be wrong", "?")
Tasks and timing
from oakley import Task
import time
with Task("Compute something heavy"):
time.sleep(1.2)
Progress bar
from oakley import ProgressBar
import time
for i in ProgressBar(range(50), size=50):
time.sleep(0.02)
if i == 25:
ProgressBar.whisper("Halfway there!")
Status helpers
from oakley import MemoryView, DateTime()
MemoryView() # prints a short memory usage line (requires psutil)
DateTime()
Mute and indentation
from oakley import MutableClass, Message
MutableClass.mute() # globally mute printing
MutableClass.unmute()
with Message.mute():
Message.print("This won't be printed")
Message.print("This will be printed again!")
with Message("The following messages will be indented"): # increase indentation for nested prints
Message.print("This will be indented")
MemoryView() # also indented
Message("This won't be indented")
Examples
Take a look at this notebook for the most detailed and up to date examples.
Alternatively, run the command:
python -m oakley.<filename_without_dot_py>
to see examples for each object.
Finally, see this script for an example on how to use the @cli decorator on a function.
Development notes
- The package is intentionally tiny and uses ANSI escape sequences for coloring; compatibility is best on UNIX-like terminals.
MemoryViewdepends onpsutil— the package runs fine even whenpsutilis not available, but theMemoryViewobject cannot be used.- There are simple demo blocks in each module under
if __name__ == '__main__'for manual testing.
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 oakley-3.2.0.tar.gz.
File metadata
- Download URL: oakley-3.2.0.tar.gz
- Upload date:
- Size: 32.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5adba9590948d3a522c6741629408bb93178a40840a2aaa4efa5c4f1186c902
|
|
| MD5 |
879513b71b52100769a49787d6ebcb4a
|
|
| BLAKE2b-256 |
da276ab86fc0971af6513a6bfa482cfe016f18c00800c140eb7d4e615969140a
|
File details
Details for the file oakley-3.2.0-py3-none-any.whl.
File metadata
- Download URL: oakley-3.2.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09b4aed3f394408f340ceb958874e74340b5b0476192ae77260717e7a842018b
|
|
| MD5 |
66400d26e76613e817fbb6f17f354603
|
|
| BLAKE2b-256 |
51b6b75393d7ef7daea0ec1f375fd1d952a81ed6b4b22b359c669b150b0810a4
|