🧰 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.
Metadata
Release files for ten-utils 0.0.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ten_utils-0.0.16.tar.gz | 16.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ten_utils-0.0.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.2 kB
Release files / ten_utils-0.0.16.tar.gz
| Download URL | ten_utils-0.0.16.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11b63b61db521b089eb68af32be686e49d4762abdb6ae335877a0f7f28b38337
|
|
BLAKE2b-256 checksum How to use checksums |
5ee023005612fdd552acc99a29b0e99f6b3e7624a787f61a02bb909772889cef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / ten_utils-0.0.16-py3-none-any.whl
| Download URL | ten_utils-0.0.16-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f396615fddd83029d2f43bc66676a1bc204fdc4f4d12c0ffe949734360a9626a
|
|
BLAKE2b-256 checksum How to use checksums |
16be1333cca83bf4443332d7531537c06329d84f7fc0af4d8e994c161661c843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|