A configuration utility for Python object.
Project description
colt
Introduction
colt
is a configuration utility for Python object.
colt
constructs Python object from configuration dict which is convertable into JSON.
Installation
pip install colt
Example
import typing as tp
import colt
@colt.register("foo")
class Foo:
def __init__(self, message: str) -> None:
self.message = message
@colt.register("bar")
class Bar:
def __init__(self, foos: tp.List[Foo]) -> None:
self.foos = foos
if __name__ == "__main__":
config = {
"@type": "bar", # specify type-name with `@type`
"foos": [
{"message": "hello"}, # type of this is inferred from type-hint
{"message": "world"},
]
}
bar = colt.build(config)
assert isinstance(bar, Bar)
print(" ".join(foo.message for foo in bar.foos))
# => "hello world"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
colt-0.2.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
colt-0.2.0-py3-none-any.whl
(5.1 kB
view hashes)