smallconfig
For Python 3.8+.
A small utility for managing script-specific settings and multiple
configurations. Configuration files are stored in Appdata/Roaming as
.json files. Uses only the standard library.
Quickstart
This utility contains a template class SmallConfig which handles
multiple configuration files for the same script.
Create a child class of SmallConfig that implements the
manager_name and default_config properties.
from smallconfig import SmallConfig as SmallConfigTemplate
class SmallConfig(SmallConfigTemplate):
@property
def manager_name(self):
return 'ExampleManagerName'
@property
def default_config(self):
return {
'key': 'value',
'is_example': True,
}
Then create an instance of the class. Set a default configuration to clean up function calls.
config = SmallConfig('configuration.json')
config.get('key') # returns 'value'
config.set('key', 'othervalue')
config.get('key') # returns 'othervalue'
config.set_active_config('otherconfiguration.json')
config.get('key') # returns 'value'
config.get('key', 'configuration.json') # returns 'othervalue'
Other useful functions, mostly for juggling multiple configurations:
# returns a list of full file paths to configs with given manager name
config.get_configs()
# gets the config dictionary of a given config name
config.get_config('config.json')
# reloads the cache of a config directly from a file
config.reload()
# creates a new configuration file (with default settings)
config.create_config('newconfig.json')
# sets the default configuration
config.set_active_config('otherconfig.json')
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
smallconfig-1.0.1.tar.gz
(3.8 kB
view details)
File details
Details for the file smallconfig-1.0.1.tar.gz.
File metadata
- Download URL: smallconfig-1.0.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42128b7c1b65744493e961072f38d680193a44834d76b5203813585a80a18b3f
|
|
| MD5 |
372fbcefadc98d640f3e83acb77a2469
|
|
| BLAKE2b-256 |
470cb61cfe9145692556ab8b31294831c500f86e05e84a2836b41ad22d774a75
|