Skip to main content

License: MIT PyPI package version Downloads

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

Back to top

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

Back to top

About the author

Hello world, I'm Alex, a tech enthusiast ! Feel free to get in touch with me !




Back to top

Metadata

Release files for kvf 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kvf 0.0.3
File Size Uploaded
kvf-0.0.3.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kvf 0.0.3
File Interpreter ABI Platform
kvf-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / kvf-0.0.3.tar.gz

Download URL kvf-0.0.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f4885b1bbe66c8c20fdabe5cedeb3c0e5d12a54ac495f9e5fcf6fed0e0c51b73
BLAKE2b-256 checksum
How to use checksums
9cf8e1826c156d4f97cf4662a6110cbbcfd91b5e5570c8a88bf0a8270718621e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / kvf-0.0.3-py3-none-any.whl

Download URL kvf-0.0.3-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d666e51cae512e3f95c55b77524e34d0095b278c81f96f7bbc7d37b5bd545c6
BLAKE2b-256 checksum
How to use checksums
a8db4a8d3b1fef45cabcadf36f9a2231b2cde3dddd3a58ab1723119c7fbce34f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page