Python powertool in your pocket 🔨
pocketwelt purpose is to provide basic tools for Python projects.
Idea for this package came from my personal experience of repeating certain methods over and over again - quite simple, but yet too complex to keep them in my memory at all times.
Hopefully pocketwelt will help you as it helps me - as a pocekt tool that comes in handy when I want to kickstart development as fast as possible or simply forgot about simple base64 encoding ;)
Worth noting - package uses only built-in Python libraries. My purpose is to keep this as vanilla as possible, so it does not collide with other dependencies you might have in your project.
pocketwelt is available on PyPi and you can install it via pip:
pip install pocketweltYou can also install it straight from git:
pip install git+https://github.com/neurowelt/pocketwelt.gitSince this package is built using only vanilla Python libraries you can start using it right away after installing! Check out a few examples to get you going:
pocketwelt comes with a neat CustomLogger class that provides colored logs and simple file based logging. You can create as many loggers as you want by simply calling the following method:
from pocketwelt import getCustomLogger
error_logger = getCustomLogger("Error Logger", "ERROR")
info_logger = getCustomLogger("Info Logger", "INFO")
# Use as usual
error_logger.error("Error")
error_logger.info("Info that won't log")
info_logger.info("Info")Often times when working with large dictionaries that contain more complex types you may want to save your current class for later to quickly reload it. You can more than easily use the following methods to do this:
from pocketwelt import save_pickle, load_pickle
from your_script.complex_class import CustomClass
# Perform some operations with your class
llm = CustomClass()
llm.func()
llm.calc()
# Save object for later
save_pickle(llm, "llm.pkl")
# Reload it back
llm = load_pickle("llm.pkl")You never know when you're going have to decode some base64 objects - that's where the encodings module comes in! For example, decoding base64 image to PIL.Image never have been easier:
from pocketwelt import b64_decode
from PIL import Image
decoded_obj = b64_decode(b64_image)
image = Image.open(decoded_obj)Tip
Check out the official documentation to read in detail about every single method and their limitations!
If you have a tool in your mind that you would like to see added to this package - feel encouraged to setup an issue, create a pull request with your own code or just write to me with anything that comes to your mind!
Whenever you see a bug, vulnerability or place for enhancement, also do not hesitate to open an issue describing your findings. Any contribution will be greatly appreciated <3
When going through the tests directory you will find a painting of Gandalf (see original) that I use for testing. It was created by Jef Murray, a reknown fantasy illustrator. I recommend visiting his site to see more of his work.