Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a custom directory for Confuse YAML Configuration Files

Tags:

python

yaml

I'm trying to use this library for setting up a YAML config file for a python project, but I don't want to use the suggested directories for configuration e.g. ~/.config/app or /etc/app for linux. I've tried setting the path using an environment variable as outlined in the documentation here.

Does anybody have any experience of getting this to work using the environment variables?

I can't really understand why the API doesn't just let you pass a file path, this approach seems unnecessarily complex to me. I suspect there is a good reason I just don't understand! I would have thought in most cases the config file will be in your python project directory?

like image 255
soundofsilence Avatar asked Oct 26 '22 17:10

soundofsilence


1 Answers

I'm experimenting with the library and so far in order to put a config.yaml file in the root folder of my script I just did that:

import confuse


class MyConfiguration(confuse.Configuration):
    def config_dir(self):
        return './'


config = MyConfiguration('SplitwiseToBuckets')

print(config)

Quite rude I know but for what I want so far it works..! :D

like image 156
Pere Picornell Avatar answered Nov 15 '22 05:11

Pere Picornell