A library for managing settings
Project description
Settngs
This library is an attempt to merge reading flags/options from the commandline (argparse) and settings from a file (json).
It is a modified argparse inspired by how flake8 loads their settings. Note that this does not attempt to be a drop-in replacement for argparse.
Install with pip
pip install settngs
A trivial example is included at the bottom of settngs.py with the output below (using bash). For a more complete example see ComicTagger.
$ python -m settngs
Hello world
$ python -m settngs --hello lordwelch
Hello lordwelch
$ python -m settngs --hello lordwelch -s
Hello lordwelch
Successfully saved settings to settings.json
$ python -m settngs
Hello lordwelch
$ python -m settngs -v
Hello lordwelch
merged_namespace.values.Example_Group__verbose=True
$ python -m settngs -v -s
Hello lordwelch
Successfully saved settings to settings.json
merged_namespace.values.Example_Group__verbose=True
$ python -m settngs
Hello lordwelch
merged_namespace.values.Example_Group__verbose=True
$ cat >settings.json << EOF
{
"example": {
"hello": "lordwelch",
"verbose": true
},
"persistent": {
"test": false,
"hello": "world"
}
}
EOF
$ python -m settngs --no-verbose
Hello lordwelch
$ python -m settngs --no-verbose -s
Hello lordwelch
Successfully saved settings to settings.json
$ python -m settngs --hello world --no-verbose -s
Hello world
Successfully saved settings to settings.json
$ python -m settngs
Hello world
settngs.json at the end:
{
"Example Group": {
"hello": "world",
"verbose": false
},
"persistent": false,
"hello": "world"
}
What happened to the 'i'?
PyPi wouldn't let me use 'settings'
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 settngs-0.11.1.tar.gz.
File metadata
- Download URL: settngs-0.11.1.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0032724586143e5ef247fa523f4a258b78c2a37d45ab033eec4d986bab5771e
|
|
| MD5 |
074026d900ff59f08c3742f413ae1cbd
|
|
| BLAKE2b-256 |
29b2c09272be3353bd3ead2d439f849212c80ea2f873c739ca524002cded0081
|
File details
Details for the file settngs-0.11.1-py3-none-any.whl.
File metadata
- Download URL: settngs-0.11.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
755d646c45fd734d10622d43712ad2cf02651ac48fee3477ea3a4b9e13182511
|
|
| MD5 |
af5e7ac6a7fb4240627490632c91ad6e
|
|
| BLAKE2b-256 |
f08bc6b47d12ee6aa683455cb76503a3bed904ee2cbf19b0fca4b461b786b10c
|