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.10.4.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

settngs-0.10.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: settngs-0.10.4.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for settngs-0.10.4.tar.gz
Algorithm Hash digest
SHA256 f8a2b67e711bc0fb2c73e7e812ccd6f3699fa8f158f6053a802ff1304d410fee
MD5 819a4bba80e54998d0023df08ac9428a
BLAKE2b-256 ef83a50dc9580517fd78e99dbe695271d6ae29bf32628b92d57ccaf18a8cce8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: settngs-0.10.4-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for settngs-0.10.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2b11adf60863bdb11a65ab7d02640e7bc674ec7dea670fdeb785044f56b9800f
MD5 7358c8b72d1f800268f828d60d2296cc
BLAKE2b-256 19b3aa3a18823a022160a691dce072a2bfec6222b03388f1bed1869b8f8f9f2a

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