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.Rst
ResetC.Br
BrightC.Di
DimC.Un
UnderscoreC.Bl
BlinkC.Rv
ReverseC.Blk
BlackC.Red
RedC.Grn
GreenC.Ylo
YellowC.Blu
BlueC.Mag
MagentaC.Cya
CyanC.Whi
WhiteC.BgBlk
BgBlackC.BgRed
BgRedC.BgGrn
BgGreenC.BgYlo
BgYellowC.BgBlu
BgBlueC.BgMag
BgMagentaC.BgCya
BgCyanC.BgWhi
BgWhite
Logging & Errors
msg(*m)
Likeprint()
but automatically appendsC.Rst
to the end.err(e: Any, ex: int=0)
Prints an error to the console in red. Ifex
is non-zero, also exits with exit code.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)
Wrapsmain
so that when it ends, all atexit functions are run, even if an exception or interrupt occurs.atexit(f: callable)
Runf
before exit. More reliable than builtinatexit
module ifexecMain()
is used, falls back on atexit otherwise.exit(ex: int=0)
Overrides builtinexit
to exit cleanly, with optional exit code.
Misc
getDictKey(d: dict, val: Any)
Returns the first key ind
whose value isval
. Raises ValueError if not found.
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
pycolorutils-1.2.2.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for pycolorutils-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26109a321b2948e3ed785253431abb1c9efada64eb6b5f6c371c860176727227 |
|
MD5 | 8e44852dc47a5a71db4119c63e5da9dd |
|
BLAKE2b-256 | 5de5bd409c5c18714e2eeba53c830b273a71ec08d25aa6d3396541f00a5e9bd9 |