The key-value file format with sections
Project description
KvF
The key-value file format with sections
Overview
A config file (config.kvf) with sections encoded with the Paradict text format:
# this comment is part of the
# unnamed section
[section 1]
id = 42
name = 'alex'
books = (dict)
sci-fi = (list)
'book 1'
'book 2'
thriller = (list)
'book 3'
Reading a config file:
import kvf
MY_CONFIG = {"section 1": {"id": 42,
"name": "alex",
"books": {"sci-fi": ["book 1",
"book 2"],
"thriller": ["book 3"]}}}
# read a config file
my_config = kvf.get_config("/path/to/config.kvf")
# my_config is a dictionary object.
# Each key-value item of the dict represents
# a section where the key is the header (string)
# and the value is the body (dictionary)
# test
assert my_config["section 1"] == MY_CONFIG["section 1"]
# load the config from a file object
with open("path/to/config.kvf", "r", encoding="utf-8") as file:
my_config = kvf.load(file)
# test
assert my_config["section 1"] == MY_CONFIG["section 1"]
Writing a config file:
import kvf
MY_CONFIG = {"section 1": {"id": 42,
"name": "alex",
"books": {"sci-fi": ["book 1",
"book 2"],
"thriller": ["book 3"]}}}
# write a config file
kvf.put_config(MY_CONFIG, "path/to/config.kvf")
# write config to a file object
with open("/path/to/config.kvf", "w", encoding="utf-8") as file:
kvf.dump(MY_CONFIG, file)
Testing and contributing
Feel free to open an issue to report a bug, suggest some changes, show some useful code snippets, or discuss anything related to this project. You can also directly email me.
Setup your development environment
Following are instructions to setup your development environment
# create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# clone the project then change into its directory
git clone https://github.com/pyrustic/kvf.git
cd kvf
# install the package locally (editable mode)
pip install -e .
# run tests
python -m tests
# deactivate the virtual environment
deactivate
Installation
KvF is cross-platform. It is built on Ubuntu and should work on Python 3.5 or newer.
Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
Install for the first time
pip install kvf
Upgrade the package
pip install kvf --upgrade --upgrade-strategy eager
Deactivate the virtual environment
deactivate
About the author
Hello world, I'm Alex, a tech enthusiast ! Feel free to get in touch with me !
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 kvf-0.0.2.tar.gz.
File metadata
- Download URL: kvf-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c5c0ab8966b311ad7344dc76a8c8ae1ae4604f39081c9f823597aecfc52fad0
|
|
| MD5 |
4c777fd0829c18c95dd13ed42b5dc030
|
|
| BLAKE2b-256 |
24ab05d8711ee4624ab8f2dae318c19f4a574c7504d212fdf672f4424a96db73
|
File details
Details for the file kvf-0.0.2-py3-none-any.whl.
File metadata
- Download URL: kvf-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a75102dd7bca21e74d0086f56b4fb5fdd58ededf8f9135000047d8bdfbf06574
|
|
| MD5 |
78911ec3cca6a9c17d6daf5437a73672
|
|
| BLAKE2b-256 |
53de8abdd3df58d6cb9a9bceefe97f875c3af90efa3f38fd973d43c07dc90286
|