Skip to main content

python's missing batteries

Project description

pyutilkit: python's missing batteries

build lint tests license codecov readthedocs pypi downloads build automation: yam Lint: ruff

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

Requirements

  • Python 3.10 or higher
  • No external dependencies (tzdata is automatically installed on Windows)

Links

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

pyutilkit-0.11.0.post1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyutilkit-0.11.0.post1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

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

Hashes for pyutilkit-0.11.0.post1.tar.gz
Algorithm Hash digest
SHA256 01dbadf785d9b721a09e467451c098d50b8b76f137c25acdc0af9300854c8c0d
MD5 3a228b14bf9af45a39eff1810cc3599a
BLAKE2b-256 93f9f409cb2faee83b4bf041d2e105899ba11dbbfbc120cd4e694f52f541eb9b

See more details on using hashes here.

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

Hashes for pyutilkit-0.11.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 8994f25b90a7a2dc0efbfc018b70eb034aaad4d17ceda1e9ae66e7edadd43ac6
MD5 731ec927cc34e8c406adce2830bb81d9
BLAKE2b-256 643c06d8994a0259bc2224900ae17c0208cef51d5893130c5cbcc8f4608603db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page