Setting a custom directory for Confuse YAML Configuration Files

Viewed 1460

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?

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

Related