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.
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.1.0.tar.gz
(3.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
colt-0.1.0-py3-none-any.whl
(4.8 kB
view details)
File details
Details for the file colt-0.1.0.tar.gz.
File metadata
- Download URL: colt-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb4c6d35df819cd20f96ee0060b2b0eb1852dcd9c72f6c49191b40248cb65b65
|
|
| MD5 |
2ca6a286cbe31f99aebe01a5b6a9e36d
|
|
| BLAKE2b-256 |
e2369395d46e14e5684983ae3d3788d3ae53a873262c5764d68a1eeff2fd4fe9
|
File details
Details for the file colt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: colt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3058252c54c23bcf99d934363e99ebffc7179d526c38758ec19b167cd00cbabb
|
|
| MD5 |
4c5520df72822e7a177d55a5869bb5f8
|
|
| BLAKE2b-256 |
f8e1d5361a4daf1760f7bc6eb5fa1a21570436c45f9a9f164dd9be6cf134daf0
|