A way to define configuration files through classes, save it and load configuration from json/yaml
Project description
#pyConfObject
Define configuration files from classes and its relations
It allows to load/export configuration from classes to json/yaml files easily It allows to have code completion on your configuration objects and not depend on dictionaries
Example
from numbers import Number
from confObj import ConfObj
class PgServerConf(ConfObj):
ip: str = ""
port: Number = 5432
username:str = ""
password:str = ""
class MainConf(ConfObj):
pgconf: PgServerConf = PgServerConf()
timezone:str = "UTC"
if __name__ == "__main__":
conf = MainConf()
print("Default configuration:")
print(conf.as_json())
conf.pgconf.username = "admin"
print("Modified configuration for pg: ")
print(conf.pgconf.as_json())
Usage
The idea behind this module is to create a configuration object that can be organized as a tree and IDE's code completion features can be used.
It should be used as:
- Define the structure of the whole configuration defining classes that inherit from `confObj``
- [optional] Assign default values to configuration items on code
- Output the defined configuration tree as a file (either yaml or json)
- [optional] Fix default values on the generated file
- On runtime, either load configuration or use default hardcoded values.
- [optional] On runtime, values can be changed and saved to file if necessary
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyconfobj-0.1.5.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file pyconfobj-0.1.5.tar.gz
.
File metadata
- Download URL: pyconfobj-0.1.5.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 376eca8a49037565baac061c00df1a4441ba2cd83bbd24210d8c558ea8f99143 |
|
MD5 | b8b2983a58d6ec17dcbfc1fff26d6495 |
|
BLAKE2b-256 | 78bb1211d9960d30aded2e15836cb738af2fc81f36514527212068496ce0f39f |
File details
Details for the file pyconfobj-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: pyconfobj-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8256f0cb0f314c12c9177f59837f3b77fc8e5937eb1d8c803257f84c51dde5f |
|
MD5 | b1088fa9735571bb227c34a1d99997f2 |
|
BLAKE2b-256 | 84735c791cddc65a72eb9a90ff3fcdc7fce006105bed79479633ecc1e181533a |