Skip to main content

Small utility package for my projects.

Project description

Pedros

PyPI

A small package of reusable utilities for Python projects.

Features

🔧 Easy-to-use API - All functions available directly from pedros package

📦 Dependency Management - Smart detection of optional dependencies with graceful fallbacks

🎯 Core Utilities:

  • check_dependency(name: str) -> bool - Check if a Python package is available
  • setup_logging(level: int = logging.INFO) -> None - Configure logging with optional Rich support
  • get_logger(name: str = None) -> logging.Logger - Get a pre-configured logger instance
  • progbar(iterable, *, backend: str = "auto", **kwargs) -> Iterable - Progress bar with multiple backend support
  • timed(func) -> func - Decorator to measure and log function execution time

🚀 Key Benefits:

  • Zero Configuration - Works out of the box with sensible defaults
  • Flexible Backends - Auto-detects best available progress bar (rich or tqdm)
  • Type Safe - Comprehensive type hints throughout
  • Async Support - Works with both synchronous and asynchronous functions
  • Production Ready - Robust error handling and logging

Installation

  pip install pedros

Quickstart

Easy Import API

All main functions are available directly from the pedros package:

from pedros import check_dependency, setup_logging, get_logger, progbar, timed

Logger

Basic usage:

from pedros import get_logger

logger = get_logger()
logger.info("This is an info message")

Advanced configuration:

import logging
from pedros import setup_logging, get_logger

# Configure logging level
setup_logging(logging.DEBUG)

# Get a custom-named logger
logger = get_logger("my_app")

logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message")

Progress Bar

Simple usage:

from pedros import progbar

# Auto-detects best available backend (rich or tqdm)
for item in progbar([1, 2, 3, 4, 5]):
    # Process item
    pass

With specific backend:

from pedros import progbar

# Force specific backend
for item in progbar(range(100), backend="tqdm", desc="Processing"):
    # Process item
    pass

Timed Decorator

Measure function execution time:

from pedros import timed

@timed
def process_data():
    # Your function implementation
    return "result"

result = process_data()  # Automatically logs execution time

Access timing information:

@timed
def my_function():
    # Function implementation
    pass

my_function()
elapsed_time = getattr(my_function, "__last_elapsed__")
print(f"Function took {elapsed_time} seconds")

Dependency Checking

Check if optional dependencies are available:

from pedros import check_dependency

if check_dependency("rich"):
    print("Rich is available!")
else:
    print("Rich is not installed")

Examples

Complete Usage Example

import logging
from pedros import check_dependency, setup_logging, get_logger, progbar, timed

# Configure logging
setup_logging(logging.DEBUG)
logger = get_logger("my_app")

# Check for optional dependencies
if check_dependency("rich"):
    logger.info("Rich is available for enhanced logging")

# Use progress bar
logger.info("Starting data processing...")
data = range(100)

@timed
def process_items(items):
    """Process items with progress tracking."""
    processed = []
    for item in progbar(items, desc="Processing items"):
        # Simulate work
        processed.append(item * 2)
    return processed

result = process_items(data)
logger.info(f"Processed {len(result)} items")

# Access timing information
elapsed = getattr(process_items, "__last_elapsed__")
logger.info(f"Processing took {elapsed:.2f} seconds")

Advanced Progress Bar Usage

from pedros import progbar

# Different backend options
for item in progbar(range(50), backend="rich", description="Rich progress"):
    pass

for item in progbar(range(50), backend="tqdm", desc="TQDM progress"):
    pass

# Disable progress bar
for item in progbar(range(50), backend="none"):
    pass

Logging Configuration

import logging
from pedros import setup_logging, get_logger

# Different logging levels
setup_logging(logging.WARNING)  # Only warnings and errors
logger = get_logger("production")

setup_logging(logging.DEBUG)   # All messages including debug
debug_logger = get_logger("development")

# Logger hierarchy
parent_logger = get_logger("app")
child_logger = get_logger("app.module")

Installation

Basic Installation

pip install pedros

With Optional Dependencies

For enhanced functionality, install with optional dependencies:

pip install pedros[rich]    # For rich logging and progress bars
pip install pedros[tqdm]    # For tqdm progress bars
pip install pedros[all]     # All optional dependencies

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub.

Support

For questions or support, please open a GitHub issue.

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

pedros-0.0.10.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

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

pedros-0.0.10-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pedros-0.0.10.tar.gz.

File metadata

  • Download URL: pedros-0.0.10.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pedros-0.0.10.tar.gz
Algorithm Hash digest
SHA256 9ccb784aca6f8e083bca9ab1ace83cebf3fc823db43980f891510b7ffcf533a8
MD5 da78641a126ff9a348a09530b860ea0c
BLAKE2b-256 1eddbdff7855fb66ae161984c3ddf5267a18fb699c7ff5e4bb078f5aee52680e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedros-0.0.10.tar.gz:

Publisher: python-publish.yml on PierreLapolla/pedros

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pedros-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pedros-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pedros-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 741dad3548954046dc8b6c74e66536a787fe2e06f58c4712b8ac668f4a9e305a
MD5 fa41492588af71a7611263d530a7ee36
BLAKE2b-256 df448b1a932548d357a2120f94a8f5474b559669dbe3453a127e98d8e98265cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedros-0.0.10-py3-none-any.whl:

Publisher: python-publish.yml on PierreLapolla/pedros

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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