Persistent configuration storage for python applications
Project description
py-AppConfig
Persistent configuration storage for python applications. Based on similar npm
modules,
because of the lack of a python
package that does something similar.
Note: This package is still under development. Core functions work just fine, and as intended. But a few QOL features need to be worked in.
Installation
# still in testing, pip package coming soon
pip install py-appconfig
# for now, package is active and working on TestPyPI
pip install -i https://test.pypi.org/simple/ py-appconfig
Usage
from appconfig import AppConfig
config = AppConfig(project_name="myProject", defaults={'a': 10, 'b': 'this is a b'})
config_values = {
'number': 1234,
'string': 'some random string'
}
for item in config_values:
config.set(item, config_values[item])
print(config.get_all())
print(config.get('number'))
print(config.get('string'))
# reset and delete config values
config.reset('a')
config.reset_all()
config.delete('string')
Option/args during init
project_name
:str
-> requiredproject_id
:str
-> optional, default =project_name
version
:str
-> optional, default =0.0.1
conf_name
:str
-> optional, default =config
(filename of config file)conf_ext
:str
-> optional, default =.json
(file extension for config file)verbose
:bool
-> optional, default =False
(for verbose logging, needs more work)defaults
:dict
-> optional, no default value, can be used to set project default settings
Note: 2 and 3 not necessary, but may be used later for project config identification and things like version migration
Module functions
from appconfig import AppConfig
config = AppConfig(project_name="myProject")
config.set('key', 'value')
config.get('key')
config.get_all()
To-do
- Atomically writing configs to prevent corruptions due to runtime errors or system crashes.
- A better validation system for config values. Right now it only makes sure it does not try to store a function.
- Type annotations. (partially done)
Related
Loosely based on the same basic concept as some npm
packages commonly used with javascript applications.
License
MIT Copyright (c) 2019-2021 Anuj Datar
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
File details
Details for the file py-appconfig-0.1.2.tar.gz
.
File metadata
- Download URL: py-appconfig-0.1.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af5910b39f6f6aba4648e7fcd24a621109334338c760d4fba517002d72bdf6c7 |
|
MD5 | bbee0b657a5646b769c2bb76d7c6ce81 |
|
BLAKE2b-256 | 53c009de193015cdb8a9a2d042c1758601ede0bc593c41f1c443cea672b8f7d0 |
File details
Details for the file py_appconfig-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: py_appconfig-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f07517d5e8b704f0e8eb13eb0a954eb9e4f4cbc927605ace63dcf053fa9ffb4 |
|
MD5 | 3b7a698d0af2b5eb6133fb3196c7d070 |
|
BLAKE2b-256 | 384d93ca6b66a1a6479a2f79119c8a89272b3044d8ae4e401f44644616d42364 |