A python library that implements many small tools that are often used in python development.
Project description
🧰 Ten Utils Library
Welcome to Ten Utils, a lightweight Python utility library designed to simplify common development tasks with robust logging, environment variable management, and more! 🚀
Features ✨
1. Logger
-
Structured and stylized logging with colored console output.
-
Five logging levels:
-
DEBUG(0) 🐞 -
INFO(1) ℹ️ -
WARNING(2) ⚠️ -
ERROR(3) ❌ -
CRITICAL(4) 🔥
-
-
Global log level threshold control.
-
Optionally include caller information and timestamps.
-
Designed for future file logging support.
Example:
from ten_utils.log import Logger
logger = Logger(name="MyModule")
logger.info("This is an info message")
logger.error("Something went wrong")
2. EnvLoader 🌱
-
Load environment variables from
.envfiles or directly from system environment. -
Automatic type casting:
str,int,float,bool,list,tuple,dict. -
Validates values and raises meaningful errors if missing or invalid.
Example:
from ten_utils.env_loader import EnvLoader
loader = EnvLoader(path_to_env_file=".env")
db_host = loader.load("DB_HOST", str)
port = loader.load("DB_PORT", int)
3. Buffer 🧰
-
Singleton-based in-memory key-value storage.
-
Useful for caching or temporary storage within your application.
Example:
from ten_utils.buffer import Buffer
buffer = Buffer()
buffer.set("user", "Alice")
print(buffer.get("user")) # Output: Alice
buffer.clear() # Clear all cached values
4. Singleton Pattern 🔒
-
Simple metaclass to create singleton classes.
-
Ensures only one instance exists.
-
Can clear instances if needed.
Example:
from ten_utils.singleton import Singleton
class MyClass(metaclass=Singleton):
pass
instance1 = MyClass()
instance2 = MyClass()
assert instance1 is instance2 # True
5. Custom Errors ❗
-
Base exception class:
TenUtilsLibError -
EnvLoader specific errors:
-
FailedLoadEnvVariables -
FailedConvertTypeEnvVar -
NotFoundNameEnvVar
-
Example:
from ten_utils import EnvLoader, FailedLoadEnvVariables
try:
loader = EnvLoader("invalid.env")
except FailedLoadEnvVariables as e:
print(e)
Installation 💾
pip install ten-utils
Quick Start ⚡
from ten_utils import Logger, EnvLoader, Buffer
# Logger example
logger = Logger(name="App")
logger.debug("Debug message")
logger.info("Info message")
# EnvLoader example
loader = EnvLoader(".env")
db_url = loader.load("DB_URL", str)
# Buffer example
buffer = Buffer()
buffer.set("token", "abc123")
print(buffer.get("token"))
Contributing 🤝
We welcome contributions! Please follow these steps:
-
Fork the repository.
-
Create a new branch.
-
Make your changes.
-
Submit a pull request.
License 📝
This project is licensed under the MIT 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 ten_utils-0.0.16.tar.gz.
File metadata
- Download URL: ten_utils-0.0.16.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11b63b61db521b089eb68af32be686e49d4762abdb6ae335877a0f7f28b38337
|
|
| MD5 |
e04c438ef33c91ee53bfb8078853aad0
|
|
| BLAKE2b-256 |
5ee023005612fdd552acc99a29b0e99f6b3e7624a787f61a02bb909772889cef
|
File details
Details for the file ten_utils-0.0.16-py3-none-any.whl.
File metadata
- Download URL: ten_utils-0.0.16-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f396615fddd83029d2f43bc66676a1bc204fdc4f4d12c0ffe949734360a9626a
|
|
| MD5 |
19a81aa5019dad68b0fd4595b579fbcd
|
|
| BLAKE2b-256 |
16be1333cca83bf4443332d7531537c06329d84f7fc0af4d8e994c161661c843
|