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}))
Metadata
Release files for airyconf 0.0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| airyconf-0.0.1.1.tar.gz | 7.6 kB | Details |
Release files / airyconf-0.0.1.1.tar.gz
| Download URL | airyconf-0.0.1.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f471a3786369b8d85948f84a5913a3f6a61ff6b4e8d44f1caf50ac951b1c23e
|
|
BLAKE2b-256 checksum How to use checksums |
5257cf39495b6208264a12efefd937e32016316ac2dff820f45b63101136ee13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.3
|