Skip to main content
Quarantined

This project has been quarantined by PyPI admins. It cannot be installed or modified until a security review is complete.

colook

Basic terminal printing: named colors, 24-bit RGB, text styles, an extended format() helper, and encrypted printing.

Installation

pip install colook

Quickstart

import colook as ck

# print with named colors and styles
ck.print("hello", color="green", styles=["bold", "underline"])
ck.print("warning!", color=ck.Color.BRIGHT_YELLOW)

# 24-bit RGB foreground / background
ck.print("hot pink", color="rgb(255, 105, 180)")
ck.print("highlight", bg=ck.bg_rgb(255, 200, 0))

# raw escape helpers
print(ck.fg(ck.Color.CYAN) + "cyan" + ck.RESET)

# formatted templating with style suffixes
print(ck.format("{name:bold+red} scored {points:>6:cyan}", name="ada", points=42))

# encrypted printing (via basic_crypt)
ck.secure_print("top secret", key="hunter2")          # e.g. 8f3ac2e4...
ck.decrypt_print("8f3ac2e4...", key="hunter2")        # top secret

Colors

Color is an IntEnum of the standard ANSI palette: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE plus the BRIGHT_* variants. Colors are accepted everywhere as a Color member, a name string ("red", "bright-red"), an "rgb(r, g, b)" string, or a raw SGR code.

Function Description
fg(color) Foreground sequence for a named color or code
bg(color) Background sequence (31 -> 41, 91 -> 101)
fg_rgb(r, g, b) 24-bit foreground sequence (38;2)
bg_rgb(r, g, b) 24-bit background sequence (48;2)
RESET Reset-everything escape string

Components outside 0-255 raise ValueError.

Styles

Style is an IntEnum with BOLD, DIM, ITALIC, UNDERLINE, BLINK, REVERSE, HIDDEN, and STRIKETHROUGH.

Function Description
style(*styles) Combined sequence, e.g. style("bold", Style.UNDERLINE) -> ESC[1;4m

Formatting

styled(text, *, color=None, bg=None, styles=None) wraps a string in escape sequences and appends RESET; with no arguments it returns the text unchanged.

format(template, ...) works exactly like str.format plus an optional style suffix after an extra colon in the format spec. Tokens are joined with + and may be color names, style names, or rgb(r, g, b):

ck.format("{value}", value=1)                    # "1"
ck.format("{msg:red}", msg="hi")                 # red "hi"
ck.format("{n:>6:bold+cyan}", n=42)              # right-aligned, bold cyan
ck.format("{hex:rgb(255, 105, 180)}", hex="ff69b4")

Specs that only look like styles (e.g. "{t:%H:%M}" for datetimes) are left untouched. print(...) mirrors builtins.print and accepts the same color / bg / styles keywords as styled.

On Windows, importing colook fixes up the console via colorama's just_fix_windows_console(): it enables virtual-terminal processing on modern consoles and translates ANSI sequences into Win32 calls on legacy ones, so colors render everywhere including PowerShell 5.1 (enable_vt() is also exported for manual use).

Encrypted printing

Built on basic_crypt symmetric ciphers; ciphertext is printed as hex so it always survives a terminal:

Function Description
encrypt_line(text, key, cipher="rc4") Encrypt and return hex
decrypt_line(blob, key, cipher="rc4") Decrypt hex back to text
secure_print(text, key, ...) Encrypt, then print the hex line
decrypt_print(blob, key, ...) Decrypt, then print the plaintext

cipher may be "rc4" or "xor"; keys may be str or bytes-like. Both print helpers accept the usual color / bg / styles / file keywords.

API overview

Name Kind
Color, Style IntEnum palettes
fg, bg, fg_rgb, bg_rgb, style, RESET escape-sequence helpers
styled, format, print formatting helpers
secure_print, decrypt_print, encrypt_line, decrypt_line encrypted printing

Everything is re-exported at the package root: import colook as ck.

Metadata

Release files for colook 1.1.3

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

Source distribution (sdist)

Source distribution for colook 1.1.3
File Size Uploaded Provenance Actions
colook-1.1.3.tar.gz 7.2 MB Without provenance Details for colook-1.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 7.2 MB

Release files / colook-1.1.3.tar.gz

Download URL colook-1.1.3.tar.gz
Size 7.2 MB
Tags Source
SHA-256 checksum
How to use checksums
8dc7261e57873c03aaaf17c6cd9301ff3b5c00d42b02827241b9bd9a3875c756
BLAKE2b-256 checksum
How to use checksums
275b3594c6e3b60383741b32f46236bb1bfc76de973109eb0634cec2f47c29a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Release files / colook-1.1.3-py3-none-any.whl

Download URL colook-1.1.3-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8960d524263c8ef189fc8070bb684d6673de5d2e07fda19ec054af82f4eeeb1e
BLAKE2b-256 checksum
How to use checksums
59434e7836215162cdf4660b34a3b210550572b4284759e558fea8ba56c8d2b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.4

Security for colook 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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