Facilitates a convenient use of configuration files

## conf

A very simple and lightweight configuration loader and parser for Python.

Supports:

• yaml files (*.yml, *.yaml)

• ini files (*.ini)

• json files (*.json)

### Installation

pip install conf

### Usage

python your_app.py --config your_config.yml

Or:

python your_app.py --config config_env_var

The --config argument can be:

• a relative path to a file;

• an absolute path to a file;

• the name of an environment variable which value holds one of the above.

You are allowed to provide multiple configuration names (separated by a single space), in which case any setting of a former configuration file can be overwritten by a setting of a later configuration file (if the name of that setting is identical).

Once you have supplied your application with some configuration, you can fetch the settings of that configuration. There are three options of how to do that.

#### Fetching your setting (option 1)

Simply get your setting from the conf module:

import conf
your_setting = conf.your_setting

#### Fetching your setting (option 2)

from conf import your_setting

#### Fetching your setting (option 3)

You can provide a default value if you are not sure the setting will be present:

import conf
your_setting = conf.get('your_setting', 'your default value')

Note: If you use an ArgumentParser in your own application for other purposes, you must use the parse_known_args() method of the parser.

#### Fetching your setting (option 4)

You can get the configuration as a dictionary and get your setting as you would get any value from a dict:

import conf
conf_dict = conf.asdict()
your_setting = conf_dict.get('your_setting', 'your default value')

### Meta

This lib was designed and written in 2018 by finetuned89 and ramonhagenaars.

## Project details

### Source Distribution

conf-0.3.1.tar.gz (3.8 kB view hashes)

Uploaded source

### Built Distribution

conf-0.3.1-py3-none-any.whl (5.2 kB view hashes)

Uploaded py3