Skip to main content

Lightweight configuration manager

Project description

airyconf

Lightweight configuration manager

Inspired by zifeo/dataconf, implemented with no required dependencies for Python 3.6+ (except Python 3.6 requires dataclasses package to support the corresponding functionality). Supports typing, dataclasses and custom classes:

from typing import List
from dataclasses import dataclass
from airyconf import parse


class CustomObject(object):
    def __init__(self, a: float):
        self.a = a
    
    def __eq__(self, other):
        return isinstance(other, CustomObject) and other.a == self.a

@dataclass
class SomeDataclass:
    b: str
    c: List[CustomObject]

json_config = '{"SomeDataclass": {"b": "str", "c": [{"a": 1.0}, {"a": 2.0}]}}'

expected = SomeDataclass('str', [CustomObject(1.), CustomObject(2.)])

assert parse(json_config, SomeDataclass) == expected

Optionally, supports yaml if installed:

from airyconf import parse_config
parse_config('file/to/config.yaml', SomeDataclass)

Thanks to rossmacarthur/typing-compat by Ross MacArthur, typing is supported for Python 3.6+ (the single-file package is copied to avoid dependencies).

Package is under development. TODO:

  • Add documentation
  • Github actions: tests & coverage & package update
  • Multiple typing arguments (Tuple[int, CustomClass, str])
  • Nested typing arguments (List[Dict[str, List[int]]])
  • Specify classes in config (a: SomeCustomClass({param: 1}))

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

airyconf-0.0.1.1.tar.gz (7.6 kB view hashes)

Uploaded Source

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