Name | simply-useful JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | A collection of reusable utility functions, classes, and decorators. |
upload_time | 2024-12-30 17:49:38 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
utility
reusable
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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
```python
import simply_useful as SU
```
### Examples
#### Dependency Checker
```python
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
```python
from simply_useful import format_bytes
print(format_bytes(1024))
```
#### Retry Decorator
```python
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
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "simply-useful",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Dayton Jones <jones.dayton@gmail.com>",
"keywords": "utility, reusable",
"author": null,
"author_email": "Dayton Jones <jones.dayton@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a6/89/c1e99bc131ed1f78b7936d81a286986cff6bb6986dd202953fa31315e30b/simply_useful-1.0.0.tar.gz",
"platform": null,
"description": "# Simply Useful\n\nA Python module providing a collection of reusable utility functions, classes, and decorators to simplify development.\n\n## Features\n\n- Dependency Management\n - dependency_checker: Check for and install missing Python modules.\n\n- Terminal Utilities\n - clear_term: Clears the terminal screen.\n\n- Formatting Utilities\n - format_bytes: Converts bytes into a human-readable string.\n - format_uptime: Formats uptime in seconds into a readable string.\n - format_number: Formats large numbers into a readable string.\n\n- Signal Handling\n - handle_interrupt: Handles interrupt signals and executes a specified action.\n\n- Decorators\n - timeit: Logs the execution time of a function.\n - retry: Retries a function with exponential backoff.\n - cache_results: Caches the results of a function to avoid recomputation.\n - measure_memory: Measures the peak memory usage of a function.\n - async_retry: Retries an async function with exponential backoff.\n\n## Usage\n\n### Importing the Module\n```python\nimport simply_useful as SU\n```\n### Examples\n\n#### Dependency Checker\n```python\nfrom simply_useful import dependency_checker\n\nREQUIRED = ['boto3', 'botocore']\nchecker = dependency_checker(REQUIRED)\nchecker.check_dependencies()\nstatus = checker.get_status()\nprint(f\"Installed: {status['exist']}\")\nprint(f\"Missing: {status['missing']}\")\n```\n#### Format Bytes\n```python\nfrom simply_useful import format_bytes\n\nprint(format_bytes(1024)) \n```\n#### Retry Decorator\n```python\nfrom simply_useful import retry\n\n@retry(max_retries=3, backoff=2.0)\ndef fetch_data():\n # Simulate a transient error\n if random.random() < 0.8:\n raise ValueError(\"Temporary failure\")\n return \"Success!\"\n\nprint(fetch_data())\n```\n#### Async Retry\n```python\nfrom simply_useful import async_retry\n\n@async_retry(max_retries=3, backoff=2.0)\nasync def async_fetch_data():\n # Simulate a transient error\n if random.random() < 0.8:\n raise ValueError(\"Temporary failure\")\n return \"Success!\"\n\nasyncio.run(async_fetch_data())\n```\n## License\n\nThis project is licensed under the MIT License.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A collection of reusable utility functions, classes, and decorators.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/daytonjones/DevPotluck/tree/main/python/SimplyUseful",
"Issues": "https://github.com/daytonjones/DevPotluck/issues"
},
"split_keywords": [
"utility",
" reusable"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dda17e184e36f40354aad0bf6f8dcbc6aa7c1b4688b5cbce99b9ad0b245bda51",
"md5": "1e2f407937dedb2ef32e4fa74edf3353",
"sha256": "c3ef2b842c2f76a5995bc2b012f7406c9517aac5f37024e1f859a5821c8fd68e"
},
"downloads": -1,
"filename": "simply_useful-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1e2f407937dedb2ef32e4fa74edf3353",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6911,
"upload_time": "2024-12-30T17:49:35",
"upload_time_iso_8601": "2024-12-30T17:49:35.860309Z",
"url": "https://files.pythonhosted.org/packages/dd/a1/7e184e36f40354aad0bf6f8dcbc6aa7c1b4688b5cbce99b9ad0b245bda51/simply_useful-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a689c1e99bc131ed1f78b7936d81a286986cff6bb6986dd202953fa31315e30b",
"md5": "4d61c67c3a0dab48609d54edbead4b71",
"sha256": "790e35fb90e124c15410488e5e1395edb775a7998d81f050d5c3efece23fc3c2"
},
"downloads": -1,
"filename": "simply_useful-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "4d61c67c3a0dab48609d54edbead4b71",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 7081,
"upload_time": "2024-12-30T17:49:38",
"upload_time_iso_8601": "2024-12-30T17:49:38.152849Z",
"url": "https://files.pythonhosted.org/packages/a6/89/c1e99bc131ed1f78b7936d81a286986cff6bb6986dd202953fa31315e30b/simply_useful-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-30 17:49:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "daytonjones",
"github_project": "DevPotluck",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "simply-useful"
}