Skip to main content

A library for managing settings

Project description

CI GitHub release (latest by date) PyPI PyPI - Downloads PyPI - License

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


Download files

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

Source Distribution

settngs-0.11.2.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

settngs-0.11.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file settngs-0.11.2.tar.gz.

File metadata

  • Download URL: settngs-0.11.2.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for settngs-0.11.2.tar.gz
Algorithm Hash digest
SHA256 f0947eed808b3adca0be20b7098580d1f8648f2a80e6ca32bcd2d0456ae387ee
MD5 dae801d28fe1e0fe513712bc24675a0b
BLAKE2b-256 6b6f975716d726bebd390d4ead06ffa83f4eaadb5a469da5aeb44d7ab0532330

See more details on using hashes here.

File details

Details for the file settngs-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: settngs-0.11.2-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.13.7

File hashes

Hashes for settngs-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 36fa353daa067edf5d241b861a8563c55ba9491d4131acf4f4bfa8f9811516dc
MD5 b82aa01f9c84f2e64b7d18e1f85aa81b
BLAKE2b-256 24ad8fd5a8654ce872eadeaa7eddfddf6fa5ef7ca020efad08d78054ceadcbd6

See more details on using hashes here.

Supported by

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