Skip to main content

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

  1. Command line input
  2. Environment variables
  3. 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")

Install

$ pip install settipy

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

settipy-1.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

settipy-1.0.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file settipy-1.0.0.tar.gz.

File metadata

  • Download URL: settipy-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 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

Hashes for settipy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c9ce432563b65d6674521627c10fe16ab4fdb66c5329e213735d3f235d3b06fc
MD5 997e2b3dc491b7251d7d70dfbd15b4e4
BLAKE2b-256 1bc2cba5089c08b6d87d317826620b3bbca24adb6a1df5658b974418e42691e0

See more details on using hashes here.

File details

Details for the file settipy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: settipy-1.0.0-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

Hashes for settipy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 501032bd3473b5c0cc69b6548c82e9d589eafdb1b4aba47fc0621ff681a17cf4
MD5 77d7c12b812646f701b5072f74aa9754
BLAKE2b-256 aeb014a866fc8fe03f7f28e8f91ef6075fbe51c31c1033a0cd2f42ae8676df9a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page