Simply Useful
A Python module providing a collection of reusable utility functions, classes, and decorators to simplify development.
Features
-
Dependency Management
- dependency_checker: Check for and install missing Python modules.
-
Terminal Utilities
- clear_term: Clears the terminal screen.
-
Formatting Utilities
- format_bytes: Converts bytes into a human-readable string.
- format_uptime: Formats uptime in seconds into a readable string.
- format_number: Formats large numbers into a readable string.
-
Signal Handling
- handle_interrupt: Handles interrupt signals and executes a specified action.
-
Decorators
- timeit: Logs the execution time of a function.
- retry: Retries a function with exponential backoff.
- cache_results: Caches the results of a function to avoid recomputation.
- measure_memory: Measures the peak memory usage of a function.
- async_retry: Retries an async function with exponential backoff.
Usage
Importing the Module
import simply_useful as SU
Examples
Dependency Checker
from simply_useful import dependency_checker
REQUIRED = ['boto3', 'botocore']
checker = dependency_checker(REQUIRED)
checker.check_dependencies()
status = checker.get_status()
print(f"Installed: {status['exist']}")
print(f"Missing: {status['missing']}")
Format Bytes
from simply_useful import format_bytes
print(format_bytes(1024))
Retry Decorator
from simply_useful import retry
@retry(max_retries=3, backoff=2.0)
def fetch_data():
# Simulate a transient error
if random.random() < 0.8:
raise ValueError("Temporary failure")
return "Success!"
print(fetch_data())
Async Retry
from simply_useful import async_retry
@async_retry(max_retries=3, backoff=2.0)
async def async_fetch_data():
# Simulate a transient error
if random.random() < 0.8:
raise ValueError("Temporary failure")
return "Success!"
asyncio.run(async_fetch_data())
License
This project is licensed under the MIT License.
Metadata
Release files for simply-useful 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simply_useful-1.0.0.tar.gz | 7.1 kB | Without provenance | Details for simply_useful-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simply_useful-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for simply_useful-1.0.0-py3-none-any.whl |
Total release size: 14.0 kB
Release files / simply_useful-1.0.0.tar.gz
| Download URL | simply_useful-1.0.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
790e35fb90e124c15410488e5e1395edb775a7998d81f050d5c3efece23fc3c2
|
|
BLAKE2b-256 checksum How to use checksums |
a689c1e99bc131ed1f78b7936d81a286986cff6bb6986dd202953fa31315e30b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / simply_useful-1.0.0-py3-none-any.whl
| Download URL | simply_useful-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3ef2b842c2f76a5995bc2b012f7406c9517aac5f37024e1f859a5821c8fd68e
|
|
BLAKE2b-256 checksum How to use checksums |
dda17e184e36f40354aad0bf6f8dcbc6aa7c1b4688b5cbce99b9ad0b245bda51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for simply-useful 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.