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 on the binary
- Ease of use in any environment examples: linux, docker, k8
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")
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-0.9.1.tar.gz
.
File metadata
- Download URL: settipy-0.9.1.tar.gz
- Upload date:
- Size: 2.8 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 | d1a1692af4ad6391fd3822d266e0205598efa2ef5a8e217590c54e77197999ce |
|
MD5 | ce3bfe10e0f832ee9094dbaef1d393ed |
|
BLAKE2b-256 | a3456571ea206f6cd2554fcb64bb368b4dabfe958810a2e10297b3a9e68f772c |
File details
Details for the file settipy-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: settipy-0.9.1-py3-none-any.whl
- Upload date:
- Size: 2.9 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 | c2756b431d35420c5ad06f9e68877418b7cfb9008e168cd110c7504648949a85 |
|
MD5 | 7df60cad8851f1eaa2a76bec0786aa24 |
|
BLAKE2b-256 | e51c78c789592f1c81210b5063ffe0e4f504d9fb32e66dabb706f55d751a1763 |