Skip to main content

Konf

Designed to simplify a process of variables usage in configuration files. Importing variables to Python must be easy!

Installation:

pip install konf

Features:

  • Easy to use

  • JSON and YAML support out of the box

  • Require typing or validation of all input data for human factor prevention

  • Python 2.7, 3+ compatible

  • Unit-tested

  • Custom format of configuration files can be used

For Python data structures validation used excellent lib kolypto/py-good

For YAML parsing used great lib of Kirill Simonov PyYAML

How to use this library

It’s pretty simple. Just look at the code.

from konf import Konf

k_ = Konf('fruits.yml')
APPLE = k_('APPLE', basestring)
ORANGE = k_('ORANGE', basestring)
BASKET_OF_MANDARINS = k_('BASKET', [basestring])
NAMED_BANANAS = k_('BANANAS', {'yellow': basestring, 'banana2': basestring})

k2_ = Konf('grades.json')
DAVID_GRADE = k2_('DAVID', int)
MARIA_GRADE = k2_('MARIA', int)

You can find more details and advanced examples about natural validation on documentation of the “good” validation library

List of supporting Exceptions after abnormal situations

ValidationError:

Raises when data from config file doesn’t match to the type_or_validator arg

IncompleteConfig:

Raises after trying to get variable that not contained in config file

ReadError:

Raises when config file can’t be read

ParseError:

Raises if third-party parser can’t parse configuration file

ReassignmentError:

Raises if variable is loading from Konf not for the first time

FileExtensionError:

Raises if extension of the config is not .yml or .json, and parse_callback arg is not specified

That’s it!

Pull-requests are welcome.

Metadata

Release files for konf 1.0

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

Source distribution (sdist)

Source distribution for konf 1.0
File Size Uploaded
konf-1.0.tar.gz 3.4 kB Details

Release files / konf-1.0.tar.gz

Download URL konf-1.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0d639c0425a37bd9f91a17d85546358a3acfb5e273009917a7e1dc8a9e8e343d
BLAKE2b-256 checksum
How to use checksums
1dfb4a002b5c6e13f7ecca716c086d6c756066d64a26964c5774474968b74ec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.3

1 release file

1.2

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1

This release

1.0 This release

1 release file

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