A Python package for processing and validating configuration dictionaries against a custom .kv file format
Project description
kvProcessor
PYPI Package
A Python package for processing and validating configuration dictionaries against a custom .kv file format.
Installation
Install via pip:
pip install kvprocessor
File format
VARIBLENAME<TYPE>:DEFAULTVAULE
Usage
from kvprocessor import LoadEnv, KVProcessor
kv_file_path = "test/test.kv" # Directory to .kv file
kv_processor = KVProcessor(kv_file_path) # Create a KV processor class
kv_keys = kv_processor.return_names() # Gets the keys (VARIBLENAME) from the .kv file
env_list = LoadEnv(kv_keys) # Loads all the ENV varibles that match those keys
validated_config = kv_processor.process_config(env_list) # Verifies that those env varibles exist and are of the correct type
print(validated_config)
This example mimics the one found in the /test directory. With the kv file of:
DATABASE_NAME<string>:none
DATABASE_USER<string>:none
DATABASE_PASSWORD<string>:none
DATABASE_HOST<string>:none
DATABASE_PORT<string|int>:none
DATABASE_DRIVER<string>:mysql+mysqlconnector
DATABASE_DIALECT<string>:none
You should get a result of:
{'DATABASE_NAME': None, 'DATABASE_USER': None, 'DATABASE_PASSWORD': None, 'DATABASE_HOST': None, 'DATABASE_PORT': None, 'DATABASE_DRIVER': None, 'DATABASE_DIALECT': None} This is because the kvProcessor is taking input from the env, and we dont have these env varibles defined. As a result these values default to the defined default value
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 kvprocessor-0.1.5.tar.gz.
File metadata
- Download URL: kvprocessor-0.1.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f53b28c97b364083e45c8760d23b9c81b398d54cdd9b600f30ffecd2e952f0
|
|
| MD5 |
778cce2c60fb46587d08e7a719b27287
|
|
| BLAKE2b-256 |
b80e27f6bb2b55be2d2d54a3cef72aba84680be1561d6c8985811393b7cbebc3
|
File details
Details for the file kvprocessor-0.1.5-py3-none-any.whl.
File metadata
- Download URL: kvprocessor-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
300d4373744ee034d3c438842015316a1f5f93daa32642f0be74dcfd179b5d18
|
|
| MD5 |
2608ee9225fd0a1b3ddb55a7b2cbb922
|
|
| BLAKE2b-256 |
33efcc95b04573bea356c284b822b900e12d59dfb815c1d83da808c93c8333f6
|