python's missing batteries
Project description
pyutilkit: python's missing batteries
Python has long maintained the philosophy of "batteries included", providing users with a rich standard library that avoids the need for third-party tools for most tasks. Some packages are so common they have achieved similar status to the standard library. Yet, certain utilities are reimplemented across countless projects. This lightweight library, with minimal dependencies, aims to eliminate that repetition.
Quick Start
Install pyutilkit:
pip install pyutilkit
Or with uv (recommended for speed):
uv pip install pyutilkit
Basic usage example:
from pyutilkit.date_utils import now
from pyutilkit.timing import Stopwatch
from pyutilkit.term import SGRString, SGRCodes
# Get current time in any timezone
from zoneinfo import ZoneInfo
tokyo_time = now(ZoneInfo("Asia/Tokyo"))
print(f"Current time in Tokyo: {tokyo_time}")
# Measure execution time
stopwatch = Stopwatch()
with stopwatch:
# Your code here
result = sum(range(1000000))
print(f"Computation took: {stopwatch.elapsed}")
# Colorful terminal output
success = SGRString("✓ Task completed", params=[SGRCodes.GREEN, SGRCodes.BOLD])
success.print()
Key Features
- 🕐 Timezone Utilities: Robust datetime handling with cross-platform timezone support, ISO parsing (including Zulu timezone), and seamless timezone conversion
- ⏱️ High-Precision Timing: Nanosecond-precision timing with human-readable formatting, lap tracking, and stopwatch functionality
- 🎨 Terminal Formatting: ANSI color codes with smart TTY detection, automatic style stripping for piped output, and convenient header formatting
- 🛡️ Error Handling: Elegant exception handling decorator that logs errors and returns defaults instead of raising exceptions
- 📁 File Utilities: Efficient SHA-256 file hashing with buffered reading for large files
- 🚀 Subprocess Enhancement: Run shell commands with real-time output streaming, automatic timing, and structured results
- 🔧 Design Patterns: Thread-safe Singleton metaclass implementation
- ✨ Zero Dependencies: Pure Python using only standard library (except optional tzdata on Windows)
- 🧪 Fully Tested: 100% test coverage with comprehensive type annotations
Documentation
- Installation Guide - Setup instructions and requirements
- Usage Guide - Comprehensive examples and tutorials for all modules
- Classes - Singleton pattern implementation
- Date Utilities - Timezone-aware datetime operations
- File Utilities - Exception handling and file hashing
- Subprocess - Enhanced command execution
- Terminal - Terminal formatting and colors
- Timing - Performance measurement and benchmarking
- Changelog - Version history and changes
- Code of Conduct - Community guidelines
Requirements
- Python 3.10 or higher
- No external dependencies (tzdata is automatically installed on Windows)
Links
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
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 pyutilkit-0.11.0.post1.tar.gz.
File metadata
- Download URL: pyutilkit-0.11.0.post1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01dbadf785d9b721a09e467451c098d50b8b76f137c25acdc0af9300854c8c0d
|
|
| MD5 |
3a228b14bf9af45a39eff1810cc3599a
|
|
| BLAKE2b-256 |
93f9f409cb2faee83b4bf041d2e105899ba11dbbfbc120cd4e694f52f541eb9b
|
File details
Details for the file pyutilkit-0.11.0.post1-py3-none-any.whl.
File metadata
- Download URL: pyutilkit-0.11.0.post1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8994f25b90a7a2dc0efbfc018b70eb034aaad4d17ceda1e9ae66e7edadd43ac6
|
|
| MD5 |
731ec927cc34e8c406adce2830bb81d9
|
|
| BLAKE2b-256 |
643c06d8994a0259bc2224900ae17c0208cef51d5893130c5cbcc8f4608603db
|