Hectiq Config
This Python module provides a powerful and flexible configuration management system based on Pydantic models. It is designed to create, manage, and validate configurations with ease.
Features
- Dynamic Configuration Classes: Utilize Pydantic to dynamically create configuration models from dictionaries.
- Validation and Casting: Validate configurations against a defined template and cast configurations to ensure correct types and structures.
- Serialization and Deserialization: Load and save configurations from and to JSON files using
orjsonfor efficient IO operations. - Nested Configurations: Support for nested configurations, allowing complex, hierarchical settings to be managed cleanly and efficiently.
Dependencies
pydantic: Used for creating data models and validation.orjson: Used for fast JSON serialization and deserialization.re: Used for regex operations, particularly in handling aliases in configuration keys.
Installation
pip install hectiq-config
Usage
Creating a Configuration
from hectiq_config import Config
config = Config(a="12345", b=12345, c=[1, 2, 3], d={"x": 1, "y": 2})
Loading and Saving Configurations
config.save('path/to/config.json')
loaded_config = Config.load('path/to/config.json')
Validating Configurations
You can validate a configuration against a template to ensure it has the correct structure and types. A template is a dictionary that defines the expected structure of the configuration.
For example, define a template as follows:
template = {
"a": str,
"b": int,
"c": list,
"d": {
"x": int,
"y": int
}
}
Then validate the configuration against the template:
is_valid = config.validate(template=template, raise_exception=True)
Release files for hectiq-config 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hectiq_config-1.1.0.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hectiq_config-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / hectiq_config-1.1.0.tar.gz
| Download URL | hectiq_config-1.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
423b08a368f5b401c46f654e3e53d4deb23f3760dbb5cd955148654d4500105d
|
|
BLAKE2b-256 checksum How to use checksums |
f6eedda081ab8f77eb90c83d71d253345090a8ddde9fe8556bfc72c13dcda2f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / hectiq_config-1.1.0-py3-none-any.whl
| Download URL | hectiq_config-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07deeab27b4201a3748d5b51d08b34474e980202272d60ffba5b4bf71d0a23e3
|
|
BLAKE2b-256 checksum How to use checksums |
af0a920d197cb3124246f71e0c3c5f5c4cc2131e33e75660a10552f4f850edde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|