pylibconfig2
Pure python library for libconfig syntax. IO works via strings, and include directives.
Usage
Scalar types are pythons basic types str, int, long, float, bool. The libconfig types Array, List, Group are implemented as ConfArray, ConfList, ConfGroup, respectively. A config is setup from a string only, and represented as a string automatically.
The config
Config represents a libconfig configuration. The string representation is itself readable as a config. Access works via attributes:
>>> import pylibconfig2 as cfg
>>> c = cfg.Config("my_setting = 5;")
>>> str(c)
'my_setting = 5;'
>>> c.my_setting
5
Or via lookup as in the original libconfig way (no exceptions are raised):
>>> c = Config('my = {nested = {sett = (0, {ng = "rocks!"})}}')
>>> c.lookup('my.nested.sett.[1].ng')
'rocks!'
>>> c.lookup('my.nested.foo', 'bar')
'bar'
- Setting values should be done by path (but attribution is also possible):
>>> c = Config('') >>> c.setup('foo', 1) True >>> c.setup('bar', '{hello = "world"}') True >>> c.lookup('bar.hello') 'world' >>> c.setup('a.nonexisting.group', '"returns False!"') False
These functions are given for further convenience:
keys() values() items() get(key, default) set(key, value)
An array
ConfArray represents a libconfig array. Access works via the [] operator:
>>> c = cfg.Config("my_array = [1, 2, 3];")
>>> c.my_array[1]
2
A list
ConfList represents a libconfig list. Access works via the [] operator:
>>> c = cfg.Config('my_list = (1.5, 2L, 0xee, "string");')
>>> c.my_list[1]
2L
A group
ConfGroup represents a libconfig group. Access works via attributes:
>>> c = cfg.Config("my_group = {my_setting = 5;};")
>>> c.my_group.my_setting
5
Again, these functions are given for convenience:
keys() values() items() get(key, default) set(key, value)
Metadata
Release files for pylibconfig2 0.2.5
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 | |
|---|---|---|---|---|
| pylibconfig2-0.2.5.tar.gz | 5.3 kB | Without provenance | Details |
Release files / pylibconfig2-0.2.5.tar.gz
| Download URL | pylibconfig2-0.2.5.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
186bd2d88356036ac8770195c8a3e9bac3ccdb3b9e6ecf04be62c307760895c7
|
|
BLAKE2b-256 checksum How to use checksums |
4f217f8e9c2c9227a7f78106c16583166b6f38701e75cf33e19737397868b81c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pylibconfig2 0.2.5
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.