Skip to main content

Easy settings for Python projects

Project description

This module provides a spy object that resolves an attribute by searching sequentially in following places:

  1. manually set settings

  2. settings catalog

  3. user-provided settings module

  4. manually set fallbacks

Examples:

  1. Manally set settings:

from settingspy import spy spy[‘this_is_int’] = 123 spy[‘this_is_str’] = ‘string’ print(spy.this_is_int, spy.this_is_str)

  1. Settings catalog

Inside the directory specified by the SETTINGSPY_CATALOG environment variable, a file named something may exist with the desired value. File contents are restricted to booleans, integers, floats, strings. They are parsed as if eval()ed, so strings should be wrapped in parentheses.

$ echo 123 > “$SETTINGSPY_CATALOG/this_is_int” $ echo “‘string’” > “$SETTINGSPY_CATALOG/this_is_str”

  1. User provided settings module

in file mysettings.py: this_is_int = 123 this_is_str = ‘string’

import os; os.environ[‘SETTINGSPY_MODULE’] = ‘mysettings’ from settingspy import spy; print(spy.this_is_int, spy.this_is_str)

  1. Manually set fallbacks

In case a setting attribute isn’t defined anywhere else.

from settingspy import spy spy.setfallback(‘this_is_int’, 123) spy.setfallback(‘this_is_str’, ‘string’)

For more details see the source code at https://github.com/ydm/settingspy

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

settingspy-1.1.2.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file settingspy-1.1.2.tar.gz.

File metadata

  • Download URL: settingspy-1.1.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for settingspy-1.1.2.tar.gz
Algorithm Hash digest
SHA256 cb21642469a5982cc068bc4194e8b9afb26df72df1bbe457ccac8f4b966a4ced
MD5 3c12a0f4e60a744990574f5158761a93
BLAKE2b-256 a1c582c5b89ae4090861804b9352200e3346f788fc4e24c3331a1bc87ff8b033

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