Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yaml
- import os
- import easydict
- import threading
- CONFIGS = [
- '/etc/avgjoe/useful_stuff/config.yaml',
- '~/.config/avgjoe/useful_stuff/config.yaml',
- '~/.useful_stuff_config.yaml']
- class Config:
- __cfg = None
- __lock = threading.Lock()
- @classmethod
- def get(cls):
- with cls.__lock:
- if cls.__cfg is None:
- cls.__cfg = Config.load()
- return cls.__cfg
- @staticmethod
- def load():
- for conf in CONFIGS:
- try:
- with open(os.path.expanduser(conf), 'r') as f:
- cfg = easydict.EasyDict(yaml.safe_load(f))
- break
- except IOError as e:
- pass
- return cfg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement