Project config files
Project description
What is this?
A nice way to integrate a generic config file into the rest of your project
How do I use this?
pip install quik-config
Create a config file like info.yaml
with a structure like this:
# NOTE: names in parentheses are special
# all other names are not special
(project):
# paths the code will probably need to use
(path_to):
config_file: "./"
# this is your local-machine config choices
# (should point to a file that is git-ignored)
# (this file will be auto-generated with the correct format)
(configuration): ./configuration.ignore.yaml
# below are options that the config file can choose
# when multiple options are selected
# their keys/values will be merged recursively
(configuration_options):
(default):
mode: development
has_gpu: false
constants:
pi: 3 # its 'bout 3
DEV:
mode: development
PROD:
mode: production
has_gpu: true
TEST:
mode: testing
GPU:
has_gpu: true
from quik_config import find_and_load
# NOTE: intentionally changes directories to be in the same folder as the config
config = find_and_load("info.yaml", default_options=["DEV"]).config # will keep going up a directories looking for the file
print(f'''config.has_gpu = {config.has_gpu}''')
print(f'''config.constants.pi = {config.constants.pi}''')
# same as above but will not change your directory
config = find_and_load("info.yaml", default_options=["DEV"], go_to_root=False,).config
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quik_config-0.0.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for quik_config-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f8f8e0ebe8c3866dc69526a47c6cf55b32f2137aa8ec7eb3c6f73da6d6ec1f |
|
MD5 | e814576b6360507f53797d8de314c601 |
|
BLAKE2b-256 | cf28f5c3c11f6d65dc2dc5e964d5cc0f0ffc38ec104ae1faa386b1c0a0803ebd |