An object orianted config module that implements json files with structured objects to manage setting files
Project description
oop_config
This module's intend is to simplify the process of creating and managing config files by implementing json files with structured object call to get or set configuration items.
How it works?
First,, you import the Config class, which is the only class to be actually used. from config import Config
then you just create one config object, passing the path of the settings file to be loaded or created, along with an optional parameter to pass a dictionary for default settings
if the default dictionary is passed, all its keys will be used as class properties to access and edit those configurations directly. if the default dictionary contained nested dictionaries, all those sub dictionaries will be converted into sections and will be accessed directly like this config.section1.item1 = "newvalue"
There are helper methods to add individual setting items or sections to the base config object and sections. Use: config.add_setting(name, value) to add individual settings, or config.add_section(section_name, optional_default_settings) to add full section the same is applyed to sections. use config.section.add_setting to add individual settings into sections, and config.section.add_section to nest another section into that section
example
from oop_config import Config
config = Config("settings.json", {"debug": True}) print(config.debug) config.debug = False print(config.debug) config.add_setting("path", "default") config.path = "documents" config.add_section("keyboard") config.keyboard.add_setting("delay", 5) config.keyboard.add_section("hotkeys") config.keyboard.hotkeys.add_setting("exit", "esc") config.keyboard.hotkeys.exit = "alt+f4"
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
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
File details
Details for the file oop_config-0.1.tar.gz.
File metadata
- Download URL: oop_config-0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61b41496203e4d629d8559dea8893b24e968dc268928f54b8b10053eabd9e645
|
|
| MD5 |
ce3e8e64a5f360019a25ae0228b98c29
|
|
| BLAKE2b-256 |
90be3dd83fe60cb83ccb1304810cb72f8f3d8de5a26e204ccb3458407c133e3f
|
File details
Details for the file oop_config-0.1-py3-none-any.whl.
File metadata
- Download URL: oop_config-0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85d711a68fe5609dfc375e2a330bddaae493f8fa241f410575c24b58ab9e2e4c
|
|
| MD5 |
2ceface0aeb134692ea6d73feac6da1f
|
|
| BLAKE2b-256 |
04762dfa8d54a46d0615170e87a9606d32f3fcbbb47e2eb963a28a95a83ee002
|