A collection of common python utilities.
Project description
mooch
mooch is a lightweight Python utility library designed to streamline common development tasks needed for every python project — file handling, path operations, logging decorators, and more — all in one convenient minimum package.
Table of Contents
✨ Features
Location Class
Provide a zip code to get city, state and lat, lon.
Require Class
Raise an exception if the installed python version is not compatible with a script. Raise an exception if the desired operating system is not compatible with a script.
Logging Decorators
@log_entry_exit
- Logs the entry and exit of the function, including the arguments.
- Useful for debugging and tracing.
Function Decorators
@silent(fallback="fallback value")
- Suppresses exceptions raised within the decorated function.
- Returns
fallbackif an exception is caught.
@retry(3)
- Retries the decorated function if an exception is raised.
- Returns the last exception on final retry attempt. Optional
fallbackreturned instead if desired. - Set delay time between tries with
delayargument.
🛠 Install
pip install mooch
or
uv add mooch
📌 Dependencies
Python 3.9 or greater
💡 Usage
Browse the examples folder for more examples.
Logging Decorator
from mooch.decorators import log_entry_exit
@log_entry_exit
def random_function(arg1, arg2):
print(arg1)
print(arg2)
Log File Output:
DEBUG:__main__:Entering: random_function with args=('Hello', 'World'), kwargs={}
DEBUG:__main__:Exiting: random_function
Retry Decorator
from mooch.decorators import retry
@retry(3)
def get_age(name="random_person"):
age = ...some other task...
return age
Location
from mooch import Location
location = Location(62704).load()
print(location.city) # "Springfield"
print(location.state) # "Illinois"
print(location.state_abbreviation) # "IL"
print(location.latitude) # "39.7725"
print(location.longitude) # "-89.6889"
Require
Raise an Exception if the requirement isn't satisified.
from mooch import Require
Require.python_version("3.13")
Require.operating_system("Windows")
🏆 Contributing
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
Bug Reports and Feature Requests
Please use the issue tracker to report any bugs or request new features.
Contributors
📃 License
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 mooch-1.0.0.tar.gz.
File metadata
- Download URL: mooch-1.0.0.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f86ce325a2539cd3c39d9f64b4c94756a49d02cb4a407c5741e751ae0896f199
|
|
| MD5 |
a681bbc18be53921b6baf05a9eef42d5
|
|
| BLAKE2b-256 |
809fadd7276a39d78aeca2fc03ab95c3f1d17dbca4fcf4aefc2a954344b5fa8b
|
File details
Details for the file mooch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mooch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a60fad09cd0f32a3c1d4e49fca6e9525f45cfb01329b2e6b4024e2da81c361
|
|
| MD5 |
82c22a0d324f8b8cd1c637d904e1b4d0
|
|
| BLAKE2b-256 |
993bd3a8fffcca4e71928da4aac44a662f9356de232356280a48c07db5fcbf7b
|