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.1.tar.gz (23.5 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.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for settngs-0.11.1.tar.gz
Algorithm Hash digest
SHA256 e0032724586143e5ef247fa523f4a258b78c2a37d45ab033eec4d986bab5771e
MD5 074026d900ff59f08c3742f413ae1cbd
BLAKE2b-256 29b2c09272be3353bd3ead2d439f849212c80ea2f873c739ca524002cded0081

See more details on using hashes here.

File details

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

File metadata

  • Download URL: settngs-0.11.1-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.12.9

File hashes

Hashes for settngs-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 755d646c45fd734d10622d43712ad2cf02651ac48fee3477ea3a4b9e13182511
MD5 af5e7ac6a7fb4240627490632c91ad6e
BLAKE2b-256 f08bc6b47d12ee6aa683455cb76503a3bed904ee2cbf19b0fca4b461b786b10c

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