Skip to main content

PyColorUtils

A set of useful utilities for Python. Same vibe as C-Utils and Utils.js.

Install via pip install pycolorutils

Color

Color Preset Strings

Format strings for console printing.

  • C.Rst Reset
  • C.Br Bright
  • C.Di Dim
  • C.Un Underscore
  • C.Bl Blink
  • C.Rv Reverse
  • C.Blk Black
  • C.Red Red
  • C.Grn Green
  • C.Ylo Yellow
  • C.Blu Blue
  • C.Mag Magenta
  • C.Cya Cyan
  • C.Whi White
  • C.BgBlk BgBlack
  • C.BgRed BgRed
  • C.BgGrn BgGreen
  • C.BgYlo BgYellow
  • C.BgBlu BgBlue
  • C.BgMag BgMagenta
  • C.BgCya BgCyan
  • C.BgWhi BgWhite

Logging & Errors

  • msg(*m) Like print() but automatically appends C.Rst to the end.
  • err(e: Any, ex: int=0) Prints an error to the console (stderr) in red. If ex is non-zero, also exits with exit code.
  • warn(w: Any) Prints a warning to the console (stderr) in yellow.
  • eInfo(e: Exception) Returns a human-readable string for the exception.
  • onMsg = callable(m: str) If defined, redirects output from msg()
  • onErr = callable(e: str) If defined, redirects output from err()

Main & Exit

  • execMain(main: callable) Wraps main so that when it ends, all atexit functions are run, even if an exception or interrupt occurs.
  • atexit(f: callable) Run f before exit. More reliable than builtin atexit module if execMain() is used, falls back on atexit otherwise.
  • exit(ex: int=0) Overrides builtin exit to exit cleanly, with optional exit code.

Misc

  • clear(all=True) Clear the console.
  • setCursor(x: int, y: int) Set the text cursor position to (x, y).
  • getDictKey(d: dict, val: Any) Returns the first key in d whose value is val. Raises ValueError if not found.

UUID

Python port of the 64-bit ChuID UUID format. ChuID outputs as a compact, 11 character Base64 string. It's made for situations where a longer 128-bit format like UUIDv4 is overkill.

Format: <U8 Uptime><U8 Magic><U8 CryptoRand><U8 Counter><U32 Date>

from uuid import UUID

#Current date, magic value 15
id = UUID.genUUID(None, 15)

print(id.id, f"String: {id}\n",
	id.date(), id.magic())

Methods

  • UUID(id) Construct ID from bytes or str
  • UUID.genUUID([date[, magic]]) Generate new random UUID w/ optional date and magic

Reader

TODO Detailed help coming soon!

FancyTable

Render a fancy table in the console w/ colored borders and a header row.

  • table(title: str, width: int, colNames: list[str], data: list[list[str]], color: str='')
  • strLen(s: str) Get length of string without control sequences.
  • center(s: str, width: int, end: bool=True, sep: str='') Draw centered text w/ optional separator.
  • sep(width: int, div: list=None, sep: str='-', clr: str='') Draw table heading separators.

Metadata

Release files for pycolorutils 1.2.9

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

Source distribution (sdist)

Source distribution for pycolorutils 1.2.9
File Size Uploaded Provenance Actions
pycolorutils-1.2.9.tar.gz 20.6 kB Without provenance Details for pycolorutils-1.2.9.tar.gz

Built distribution (wheel)

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

Total release size: 40.9 kB

Release files / pycolorutils-1.2.9.tar.gz

Download URL pycolorutils-1.2.9.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c80e892c9431edc0b61535abb3b1ba6dd0c189eeec6a53b673d14c9a35d3e2ce
BLAKE2b-256 checksum
How to use checksums
f4dc9534b47a9fba02932b512741f77333968c12b9f52db0bf44256f9b8702f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / pycolorutils-1.2.9-py3-none-any.whl

Download URL pycolorutils-1.2.9-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
651adedb6818dc17947eeed10439458063c819fb4dc2f47456bb452c7a41addf
BLAKE2b-256 checksum
How to use checksums
3083395a0f45fe42dff4fb7e6dbb13aefaa97882a3cbe56bd9f26ca4c2a04a61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Security for pycolorutils 1.2.9

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.

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