Small utility package for my projects.
Project description
Pedros
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 availablesetup_logging(level: int = logging.INFO) -> None- Configure logging with optional Rich supportget_logger(name: str = None) -> logging.Logger- Get a pre-configured logger instanceprogbar(iterable, *, backend: str = "auto", **kwargs) -> Iterable- Progress bar with multiple backend supporttimed(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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ccb784aca6f8e083bca9ab1ace83cebf3fc823db43980f891510b7ffcf533a8
|
|
| MD5 |
da78641a126ff9a348a09530b860ea0c
|
|
| BLAKE2b-256 |
1eddbdff7855fb66ae161984c3ddf5267a18fb699c7ff5e4bb078f5aee52680e
|
Provenance
The following attestation bundles were made for pedros-0.0.10.tar.gz:
Publisher:
python-publish.yml on PierreLapolla/pedros
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pedros-0.0.10.tar.gz -
Subject digest:
9ccb784aca6f8e083bca9ab1ace83cebf3fc823db43980f891510b7ffcf533a8 - Sigstore transparency entry: 782337622
- Sigstore integration time:
-
Permalink:
PierreLapolla/pedros@cd0f98810365dc1878c328d543d335048313886b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/PierreLapolla
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cd0f98810365dc1878c328d543d335048313886b -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
741dad3548954046dc8b6c74e66536a787fe2e06f58c4712b8ac668f4a9e305a
|
|
| MD5 |
fa41492588af71a7611263d530a7ee36
|
|
| BLAKE2b-256 |
df448b1a932548d357a2120f94a8f5474b559669dbe3453a127e98d8e98265cd
|
Provenance
The following attestation bundles were made for pedros-0.0.10-py3-none-any.whl:
Publisher:
python-publish.yml on PierreLapolla/pedros
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pedros-0.0.10-py3-none-any.whl -
Subject digest:
741dad3548954046dc8b6c74e66536a787fe2e06f58c4712b8ac668f4a9e305a - Sigstore transparency entry: 782337629
- Sigstore integration time:
-
Permalink:
PierreLapolla/pedros@cd0f98810365dc1878c328d543d335048313886b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/PierreLapolla
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cd0f98810365dc1878c328d543d335048313886b -
Trigger Event:
push
-
Statement type: