Skip to main content

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.
  • Message class for categorized, pretty messages (info, warning, error, success).
  • Task context manager to wrap and time operations, with neat completion/abort output.
  • ProgressBar iterator wrapper with estimated remaining time and non-intrusive whisper messages.
  • MutableClass base with global mute/tab behavior so multiple components coordinate console output.
  • Small status helpers: MemoryView, TODO and DateTime for quick runtime info.

Installation

You can downlaod the package from my GitHub repository with this command:

pip install oakley

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, TODO
MemoryView()              # prints a short memory usage line (requires psutil)
TODO("Refactor the parser")

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.

Development notes

  • The package is intentionally tiny and uses ANSI escape sequences for coloring; compatibility is best on UNIX-like terminals.
  • MemoryView depends on psutil — the package runs fine even when psutil is not available, but the MemoryView object cannot be used.
  • There are simple demo blocks in each module under if __name__ == '__main__' for manual testing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oakley-2.1.5.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oakley-2.1.5-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file oakley-2.1.5.tar.gz.

File metadata

  • Download URL: oakley-2.1.5.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for oakley-2.1.5.tar.gz
Algorithm Hash digest
SHA256 744004f99bea2da30856d588eaec6f719b36020f88b4dd344ad3bae65020942a
MD5 5fe648dd865ebee6544a9ef1e64a7c92
BLAKE2b-256 2c50aad4a7c7ab2b17318f8dc9fd8be3842d5c70c788ba7a20148c519369241a

See more details on using hashes here.

File details

Details for the file oakley-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: oakley-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for oakley-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d49bffebd50b0195c9de6d575b4eedcc17941ba5b6ea13a59aa34be5aad3c965
MD5 1d48d02422f5f0897d9189b133b5977d
BLAKE2b-256 4e78081e62d4f424a930ed9154485e2b8b3924ac471463cddf410f386ccaf5cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page