dataclasses-configobj
Hydrate Data Classes from ini/dat/toml files.
Aims to be dataclasses-json, but for configobj.
This is very alpha right now, but the feaures which work, should work:
Usage
Define the shape of your config:
- Each subsection will be mapped to a nested class
- Each subsection may define a single
_many - A
_manymust have typeList[...] - The type of
Listof a_manyshall have a_name
Example:
@dataclass
class Single:
other: str
@dataclass
class OneOfMany:
_name: str
val: str
@dataclass
class Config:
single: Single
_many: List[OneOfMany]
optional: Optional[str] = None
To load this .ini file:
[single]
other = hello
[one]
val = apple
[two]
val = banana
We can read, validate, and lift to an instance of Config with:
spec = core.to_spec(Config)
co = configobj.ConfigObj(infile=infile, configspec=spec)
validator = validate.Validator()
co.validate(validator)
config: Config = dataclasses.lift(Config, co)
To yield config:
Config(
single=Single(other='hello'),
optional=None,
withdefault='test123'
_many=[
OneOfMany(_name='one', val='apple'),
OneOfMany(_name='two', val='banana')
]
)
Metadata
Release files for dataclasses-configobj 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dataclasses-configobj-0.0.4.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dataclasses_configobj-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / dataclasses-configobj-0.0.4.tar.gz
| Download URL | dataclasses-configobj-0.0.4.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96e77cf0e2a38d66b3859e36b8224ef157452a9e14ba5091e727b0df327c3be6
|
|
BLAKE2b-256 checksum How to use checksums |
0302dced431be7626508c0244998b3f606e6df0cac27022a47ed9e6b7e58ab16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Release files / dataclasses_configobj-0.0.4-py3-none-any.whl
| Download URL | dataclasses_configobj-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
63c0372017ed80117e283ae083d65fe77258063d08100631060bb60d409de8cc
|
|
BLAKE2b-256 checksum How to use checksums |
9f25f8d134f9206c552c5daa7539f4c51a25bee45297a859ec0716ecd049d5b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Security for dataclasses-configobj 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.