~brianlbaird/charms/trusty/mme/trunk

« back to all changes in this revision

Viewing changes to lib/charms/layer.py

  • Committer: brianlbaird at gmail
  • Date: 2016-02-05 22:54:17 UTC
  • Revision ID: brianlbaird@gmail.com-20160205225417-8f89hq9ij9p2fhsy
update mme name in docker-compose.yaml

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
import os
 
3
import yaml
 
4
 
 
5
 
 
6
class LayerOptions(dict):
 
7
    def __init__(self, layer_file, section=None):
 
8
        with open(layer_file) as f:
 
9
            layer = yaml.safe_load(f.read())
 
10
        opts = layer.get('options', {})
 
11
        if section and section in opts:
 
12
            super(LayerOptions, self).__init__(opts.get(section))
 
13
        else:
 
14
            super(LayerOptions, self).__init__(opts)
 
15
 
 
16
 
 
17
def options(section=None, layer_file=None):
 
18
    if not layer_file:
 
19
        base_dir = os.environ.get('CHARM_DIR', os.getcwd())
 
20
        layer_file = os.path.join(base_dir, 'layer.yaml')
 
21
 
 
22
    return LayerOptions(layer_file, section)