CatConfig
🐱Make more easy for reading/validating/updating config for python app
Install
pip install catconfig
If you want to use validation feature, install cerberus module for your project to use it normally.
Install toml or pyyaml module for toml/yaml format parsing.
Quickstart
# Example.py
from catconfig import CatConfig, ValidationError
# Load
# Load config from string
c = CatConfig()
c.load_from_string("""
{
"foo": "bar"
}
""")
# Load config when initalizing CatConfig object
c = CatConfig(data={
'foo': 'bar'
})
# load config from file
c = CatConfig()
c.load_from_file('./tests/assests/test.json')
# Specify config type when initalizing CatConfig object
c = CatConfig(format='json')
c.load_from_file('./tests/assests/test.json')
# Specify config type when loading config file
c = CatConfig()
c.load_from_file('./tests/assests/test.json', format='json')
# Get item
print(c.foo)
# Print: bar
print(bool(c.some.value.does.nt.exists))
# Print: False
print(str(c.some.value.does.nt.exists))
# Print: None
print(c['foo'])
# Print: bar
print(c.get('foo'))
# Print: bar
# Validation
# visit https://docs.python-cerberus.org/en/stable/usage.html for more info of schema
schema = {
'foo': {
'type': 'integer'
},
'some_field': {
'type': 'string'
}
}
c = CatConfig(validator_schema=schema)
try:
c.load_from_file('./tests/assests/test.json')
except ValidationError as err:
print(err.message)
# Print:
# arr: unknown field
# foo: must be of integer type
License
MIT
Metadata
Release files for catconfig 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 | Provenance | Actions |
|---|---|---|---|---|
| catconfig-0.1.1.tar.gz | 4.4 kB | Without provenance | Details for catconfig-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| catconfig-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for catconfig-0.1.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / catconfig-0.1.1.tar.gz
| Download URL | catconfig-0.1.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
043ddd17c1372d530f046dea43f28ee3f6be9de454e781a1ab401b8f680beee0
|
|
BLAKE2b-256 checksum How to use checksums |
193a2fda7a122c51822c8bdc89f668248a288e31d5a275267bfea82d11d63122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.2 Linux/4.15.0-122-generic
|
Release files / catconfig-0.1.1-py3-none-any.whl
| Download URL | catconfig-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb91c5a794af773afc0ef897b7aa85dcb3276123289be10c08c3646b1558eedf
|
|
BLAKE2b-256 checksum How to use checksums |
f2309fd510a266814c19db31a19832e94b8320ca01932b7339e2903a0c4b0685
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.2 Linux/4.15.0-122-generic
|
Security for catconfig 0.1.1
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.