Skip to content

DefinetlyNotAI/PyUtils

Repository files navigation

PyUtils

Lightweight collection of small Python utilities used across projects: a configurable exception handler, a colored terminal printing helper, and a simple Git update manager.

Last updated: 2026-01-17

Modules

  • ExceptionHandler/ — Friendly, configurable exception formatting and handling. See ExceptionHandler/README.md for details and examples.
  • TerminalPrint/ — Console printing helper with color schemes, log-to-file and timestamp support. See TerminalPrint/README.md.
  • UpdateManager/ — Small helper to fetch and merge updates from a remote Git branch for a local repo path. See UpdateManager/README.md.

Quickstart

Install requirements (if any):

pip install -r requirements.txt

A short example using the three modules together:

from TerminalPrint import TPrint
from ExceptionHandler import Handler
from UpdateManager import GitUpdateManager

# Create a terminal printer
printer = TPrint(debug_mode=True, use_timestamps=True)

# Create an exception handler that uses the TPrint critical function
handler = Handler(show_line=True, trace=True, use_timestamp=True, print_function=printer.critical)
handler.formatter(main_color=printer.color_scheme['error'])

# Attempt an update with handling
try:
    manager = GitUpdateManager(repo_path="../UpdateManager/", branch="main")
    manager.update()
except Exception:
    handler.exception(exit_script=False)

Examples

Example scripts live under example/:

  • example/TPrint.py — demo for TerminalPrint.
  • example/ExceptionHandle.py — demo for ExceptionHandler.
  • example/Update.py — demo for UpdateManager.

Notes & Safety

  • UpdateManager calls the system git CLI and will sys.exit() on failures or when uncommitted changes are detected — ensure you have a clean working tree before running update().
  • ExceptionHandler may call sys.exit() when exit_script is enabled; prefer return_string_rather_than_print for library usage.
  • Terminal coloring uses ANSI escape codes; results may vary on non-ANSI terminals (Windows terminals recent versions and WSL work well).

Contributing

Contributions welcome — open a pull request and include tests/examples where appropriate.

License

See the LICENSE file in the repository root.

About

All best utils for python - ExceptionHandler, TPrint AND UpdateManager

Topics

Resources

License

Stars

Watchers

Forks