config_parser.py 509 B

12345678910111213141516171819202122232425
  1. import os
  2. import yaml
  3. configs = [
  4. 'application',
  5. 'namespaces',
  6. 'flask',
  7. ]
  8. # This will hold a dict of all configuration values.
  9. config = {}
  10. # Parse configuration
  11. if 'FCREPO_CONFIG_DIR' in os.environ:
  12. CONFIG_DIR = os.environ['FCREPO_CONFIG_DIR']
  13. else:
  14. CONFIG_DIR = os.path.dirname(os.path.abspath(__file__)) + '/etc'
  15. for cname in configs:
  16. file = '{}/{}.yml'.format(CONFIG_DIR , cname)
  17. with open(file, 'r') as stream:
  18. config[cname] = yaml.load(stream, yaml.SafeLoader)