settings should be simple, boring and forget-able. With settipy it will be just that.
Project description
settipy
settings should be simple, and with settipy it is.
settings parses command line and environment variables on one line. And makes it available throughout the code base. Making using settings in your project as boring and unimportant as it should be. settings vars is as simple as:
settipy.set("FOO", "default value", "help text")
getting vars out has the same level of complexity as setting the value.
settipy.get("FOO")
Features
- Simple to use
- supports command line and environment variables
- Support for types: str, int, bool
- Singleton, makes it easy to use in program anywhere in the code-base
- Supports help text with --help
- Ease of use in any environment examples: linux, docker, k8
- Force program to be run with env or cli vars.
Example
example of how to use. More can be found in the example_project
settipy.set("FOO", "default value", "handy help text")
settipy.parse()
print("foo = ", settipy.get("FOOBAR"))
The above go will produce program that can be used as follows. get handy help text set in the above example on the same line. This can get very handy when the project grows and is used in different environments
$ python example.py --help
Usage of example.py:
-FOO string
handy help text (default "default value")
When no value is given, default value is used
$ python example.py
foo = default value
Running the binary with command line input
$ python example.py -FOO bar
foo = bar
Running the binary with environment variable
$ FOO=ok;python example.py
foo = ok
Order of preference
variables are set with preference variables on the command line will have highest preference. This because while testing you might want to override environment The priority order is as follows
- Command line input
- Environment variables
- Default values
Types
settipy supports different types.
// string
settipy.set("FOO", "default", "help text")
settipy.get("FOO")
// integer
settipy.set_int("FOO", 42, "help text")
settipy.get_int("FOO")
// boolean
settipy.set_bool("FOO", True, "help text")
settipy.get_bool("FOO")
Var Should be set
settipy supports different types.
// string
settipy.set("foshure", True, "handy message", should=True)
flag: foshure handy message: should be set
Install
$ pip install settipy
License
MIT
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 settipy-1.1.1.tar.gz
.
File metadata
- Download URL: settipy-1.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 765d3409529cf79262e68ec5df179a9892d7b467e26fa5ddb1af690baa449325 |
|
MD5 | 1548bb4e7ac4b454fb77e0e281eb9849 |
|
BLAKE2b-256 | f906439bbb63e72b230a5c36d48ead3fc64780f4c83ce3141be399e32e590042 |
File details
Details for the file settipy-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: settipy-1.1.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 985c5229e7551827b3784b60b9c96451e533b97ddf03b04c6474ab162f56d4c4 |
|
MD5 | 1584f98daa1a13dbcdccd1bbc86288ab |
|
BLAKE2b-256 | 1b2fd054678dce7f4c3608b829f7d8d287b52b3f3f5d7bb3be55e4b0508022d4 |