Skip to main content

A simple config parser for python

Project description

sokconfig

Just a simple util for my personal use. This aims to make it easier to load settings.

Example

from sokconfig.settings import Settings
from sokconfig.values import IntValue


class Config(Settings):
    a = IntValue(5, min_value=0, max_value=10, mutator=lambda x: x + 1)
    b = IntValue(2, min_value=0, max_value=10, extra_validator=lambda x: x % 2 == 0, name="TestValueB")


Config.fill_empty_names()
Config.validate_values()

t = {"a": 1, "TestValueB": 4}
print(Config.get_values())

Config.set_values(t)
print(Config.get_values())
{'a': IntValue(value=6, min_value=0, max_value=10), 'b': IntValue(value=2, min_value=0, max_value=10)}
{'a': IntValue(value=4, min_value=0, max_value=10), 'b': IntValue(value=4, min_value=0, max_value=10)}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sokconfig-0.1.0.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

sokconfig-0.1.0-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page