Skip to main content

Easily find and read application configuration files.

Project description

ccaConfig

a config file utility. Will read yaml formatted config files from various locations in the following order, so that the 'nearer' files override the further ones. Finally, it checks the environment for variables and overrides any set in the config file.

The order of files to read is

/etc/appname.yaml
/etc/appname/appname.yaml
$HOME/.config/appname.yaml
$HOME/.appname.yaml
$(pwd)/appname.yaml

Any environment variables of the form

APPNAME_VARIABLENAME

will be found, chopped at the underscore, lower cased and set into the final configuration i.e: config[variablename] will exist if there is an environment variable APPNAME_VARIABLENAME.

Usage

from ccaconfig import ccaConfig

cf = ccaConfig(appname="appname")
config = cf.envOverride()

or, to not take environment variables into account:

from ccaconfig import ccaConfig

cf = ccaConfig(appname="appname")
config = cf.findConfig()

Two additional dictionaries can be supplied, the first defaultd can be used to set a default config, and the 2nd, overrided can be used for config variables that you do not want overridden by any config file found or from the environment.

from ccaconfig import ccaConfig

defd = {"environment": "dev"}
overd = {"product": "myapp"}
cf = ccaConfig(appname="appname", defaultd=defd, overrided=overd)
config = cf.envOverride()
# config["environment"] == "dev" if it is not overridden by a subsequent
# config file or from an environment variable
#
# config["product"] == "myapp" and will not be overridden, at all

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

ccaconfig-0.3.7.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

ccaconfig-0.3.7-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file ccaconfig-0.3.7.tar.gz.

File metadata

  • Download URL: ccaconfig-0.3.7.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.6.8-1-MANJARO

File hashes

Hashes for ccaconfig-0.3.7.tar.gz
Algorithm Hash digest
SHA256 7aea582ee3209511751166b292c6d7fe96575eca71c7d17d515fe6f106c778b3
MD5 3cbb9e5d46a0acfb10049c45ac2d1aa5
BLAKE2b-256 0a816755f8d64f4c1052320e134620dfa2f17486b03c9252903aa3209c12d9dd

See more details on using hashes here.

Provenance

File details

Details for the file ccaconfig-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: ccaconfig-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.6.8-1-MANJARO

File hashes

Hashes for ccaconfig-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7de54faa08b6cc89dee0b0bd59535b33ef7e9881009a47895c0f69e64b503a0a
MD5 ea7e4ae89da8291913af7cc77e0bfb53
BLAKE2b-256 79d4ebccdd9231bb8449ac823dff28d43493b170f8f8dc91a69c5c1bd74279f6

See more details on using hashes here.

Provenance

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