Skip to main content

A module for retrieving program settings from various sources in a consistant method.

Project description

IMPORTANT!

This is a fork of setoptconf . It is a temporary solution to fix prospector being unable to install due to setoptconf not working with setuptools >= 58 - see the issue here.

This package is only meant as a temporary solution to fix CI builds using prosector until setoptconf can be removed from there. Therefore do not expect this fork to be maintained and it will be purged once prospector is updated.

setoptconf-tmp

setoptconf is a Python library that can be used to retrieve program settings from a variety of common sources:

  • Command Line

  • Environment Variables

  • INI Files

  • JSON Files

  • YAML Files

  • Python Objects/Modules

The goal of this project is to define your desired settings in a simple and consistent way, and then point setoptconf at as many of the sources as you’d like to use, and let it comb them all, looking for your settings.

This README is admittedly very light on details. Full documentation will come in time. For now, here’s an example of its use:

Import the library:

import setoptconf as soc

Instantiate the manager:

manager = soc.ConfigurationManager('myprogram')

Define the settings we’d like to collect:

manager.add(soc.StringSetting('foo'))
manager.add(soc.IntegerSetting('bar', required=True))
manager.add(soc.BooleanSetting('baz', default=True))

Retreive the settings from our desired sources, combining the settings and overriding with the priority implied by the order of the sources we pass:

config = manager.retrieve(
    # This source pulls from the command line using argparse.
    soc.CommandLineSource,

    # This source pulls from environment variables that are prefixed
    # with MYPROGRAM_*
    soc.EnvironmentVariableSource,

    # This source pulls from the named INI files. It stops at the first
    # file it finds.
    soc.ConfigFileSource(('.myprogramrc', '/etc/myprogram.conf')),
)

We now have a Configuration object named config that has three attributes; foo, bar, and baz.

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

setoptconf-tmp-0.3.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

setoptconf_tmp-0.3.1-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file setoptconf-tmp-0.3.1.tar.gz.

File metadata

  • Download URL: setoptconf-tmp-0.3.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for setoptconf-tmp-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e0480addd11347ba52f762f3c4d8afa3e10ad0affbc53e3ffddc0ca5f27d5778
MD5 4f0ad7f4f02768a64e4e2c5c42c7a362
BLAKE2b-256 c1f1dda18cbb5df090c67ed879760f49ee65aa1b5d4266c66175467f61aa8f58

See more details on using hashes here.

File details

Details for the file setoptconf_tmp-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: setoptconf_tmp-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for setoptconf_tmp-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76035d5cd1593d38b9056ae12d460eca3aaa34ad05c315b69145e138ba80a745
MD5 5eb36705f32de4fcc64d3405caf8ad45
BLAKE2b-256 59986d072ea4b59693d93782b1e685547dd8e90f7880d4b3c050f67d4b9eec4f

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