A set of useful utilities for Python
Project description
PyColorUtils
A set of useful utilities for Python. Same vibe as C-Utils and Utils.js.
Install via pip install pycolorutils
Color Preset Strings
Format strings for console printing.
C.RstResetC.BrBrightC.DiDimC.UnUnderscoreC.BlBlinkC.RvReverseC.BlkBlackC.RedRedC.GrnGreenC.YloYellowC.BluBlueC.MagMagentaC.CyaCyanC.WhiWhiteC.BgBlkBgBlackC.BgRedBgRedC.BgGrnBgGreenC.BgYloBgYellowC.BgBluBgBlueC.BgMagBgMagentaC.BgCyaBgCyanC.BgWhiBgWhite
Logging & Errors
msg(*m)Likeprint()but automatically appendsC.Rstto the end.err(e: Any, ex: int=0)Prints an error to the console (stderr) in red. Ifexis 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 frommsg()onErr = callable(e: str)If defined, redirects output fromerr()
Main & Exit
execMain(main: callable)Wrapsmainso that when it ends, all atexit functions are run, even if an exception or interrupt occurs.atexit(f: callable)Runfbefore exit. More reliable than builtinatexitmodule ifexecMain()is used, falls back on atexit otherwise.exit(ex: int=0)Overrides builtinexitto exit cleanly, with optional exit code.
Misc
getDictKey(d: dict, val: Any)Returns the first key indwhose value isval. Raises ValueError if not found.
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
pycolorutils-1.2.4.tar.gz
(6.0 kB
view details)
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 pycolorutils-1.2.4.tar.gz.
File metadata
- Download URL: pycolorutils-1.2.4.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
981a67237462a10027b47761545e74bde6856edc6079b162e141b811f9bfb0a9
|
|
| MD5 |
94813f3b9ba84b8f4571b6835722c610
|
|
| BLAKE2b-256 |
331d64eac8682ebc5de7789516f178e846c6865ef4bfc61d5e7a59d0bfed2e88
|
File details
Details for the file pycolorutils-1.2.4-py3-none-any.whl.
File metadata
- Download URL: pycolorutils-1.2.4-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd664dd7b8dde57b6c45c7166e986d80f69c1e3524d78b91b6aa909bafbb742
|
|
| MD5 |
5d781d43f018d2e81c893a0ce20412e4
|
|
| BLAKE2b-256 |
a6cf8291d9d1964caa33ff063b0eaba1774a391cc86771fe45bf8fb5f97f99de
|