kvf
raw JSON → 0.0.3 verified Fri May 01 auth: no python
A Python library for reading and writing key-value files with sections, similar to INI but with a simpler format. Current version 0.0.3, early development stage.
pip install kvf Common errors
error KeyError: 'section_name' ↓
cause Attempting to access a section that does not exist in the parsed data.
fix
Check that the section name is correct or use .get() to avoid KeyError.
error TypeError: write() missing 1 required positional argument: 'data' ↓
cause Calling write() without providing the data argument.
fix
Provide the data dictionary as the second argument: write('file.kvf', data).
Warnings
gotcha The library is very early (0.0.3) and may have breaking changes without notice. ↓
fix Pin version in requirements and test thoroughly.
gotcha No built-in validation: malformed files may lead to unexpected behavior or errors. ↓
fix Ensure the input data has the correct structure (dict of dicts).
Imports
- read
from kvf import read - write
from kvf import write
Quickstart
from kvf import read, write
# Example data: sections with key-value pairs
data = {
'section1': {'key1': 'value1', 'key2': 'value2'},
'section2': {'key3': 'value3'}
}
# Write to a file
write('example.kvf', data)
# Read back
loaded = read('example.kvf')
print(loaded)
# Output: {'section1': {'key1': 'value1', 'key2': 'value2'}, 'section2': {'key3': 'value3'}}