A collection of Python utilities for file operations, logging, networking, and type conversions.
Really not that impressive, but I do use them a lot.
- File Operations: Move, copy, and delete files and directories with robust error handling
- Logging Utilities: Flexible logging configuration with console, file, and notification support
- Network Utilities: Send webhooks with JSON payloads and file uploads
- Type Conversions: Safe type conversion helpers with fallback defaults (and docker detection)
- Miscellaneous Utilities: Things that don't fit elsewhere (e.g., docker detection)
Install directly from git:
pip install git+https://github.com/zorbaTheRainy/ztrlib.gitor install with apprise:
pip install "git+https://github.com/zorbaTheRainy/ztrlib.git#egg=ztrlib[apprise]"Or upgrade:
pip install --force-reinstall git+https://github.com/zorbaTheRainy/ztrlib.gitOr requirements.txt:
ztrlib @ git+https://github.com/zorbaTheRainy/ztrlib.git- requests
- send2trash
- apprise [optional]
from ztrlib import move_file, add_console_logger, send_webhook, print_to_log
# Set up logging
add_console_logger()
# Move a file
move_file("example.txt", "/source/dir", "/target/dir")
# Send a webhook
resp = send_webhook("https://example.com/webhook", {"message": "Hello!"})
# Log a message
print_to_log.info("Webhook sent successfully and file moved.")or (no from option)
import ztrlib
# Set up logging
ztrlib.add_console_logger()
# Move a file
ztrlib.move_file("example.txt", "/source/dir", "/target/dir")
# Send a webhook
resp = ztrlib.send_webhook("https://example.com/webhook", {"message": "Hello!"})
# Log a message
ztrlib.print_to_log.info("Webhook sent successfully and file moved.")or (from option but only for things you use a lot)
import ztrlib
from ztrlib import print_to_log
# Set up logging
ztrlib.add_console_logger()
# Move a file
ztrlib.move_file("example.txt", "/source/dir", "/target/dir")
# Send a webhook
resp = ztrlib.send_webhook("https://example.com/webhook", {"message": "Hello!"})
# Log a message (direct access via from-import)
print_to_log.info("Webhook sent successfully and file moved.")MIT License