config_parser.py 524 B

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