beetbox / beetbox/confuse

configuration from the filesystem

Open
#11 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
424
Forks
57
PR merge metrics
No merged PRs in 30d

Description

In the documentation, Confit mentions taking configurations from directories. I'm guessing that means it expects a file of a prescribed name in those directories. I would rather just have a function that takes a path and returns a configuration that I can pass to `override` (#9). Then, composing a colon-separated path of configuration files in precedence order turns into this:

``` python
reduce(confit.override, map(confit.from_file, PATH.split(':')))
```

I think there is a good opportunity for directory based configuration, though. Many projects (like the users of [this other confit](https://github.com/krakenjs/confit)) want to use different sets of defaults based on different **environments**. Common environments include "development", "qa" or "staging", and "production". It would be convenient if they could have a directory of multiple configuration files named after the environments.

``` python
def from_file(env, path): # env comes first for partial application
file = path
if not file.is_file():
file = path / env
if not file.is_file():
file = path / (env + '.yml')
... # more guesses
with open(file, 'r') as stream:
return yaml.load(stream.read())
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the documentation's discussion of directory-based configuration and inspect the existing override API referenced by issue #9. Evaluate the proposed from_file(env, path) entry point, including direct paths and environment-named files, and define completion around loading the selected configuration for composition with override.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.