4 class LayerOptions(dict):
5 def __init__(self
, layer_file
, section
=None):
6 import yaml
# defer, might not be available until bootstrap
7 with
open(layer_file
) as f
:
8 layer
= yaml
.safe_load(f
.read())
9 opts
= layer
.get('options', {})
10 if section
and section
in opts
:
11 super(LayerOptions
, self
).__init
__(opts
.get(section
))
13 super(LayerOptions
, self
).__init
__(opts
)
16 def options(section
=None, layer_file
=None):
18 base_dir
= os
.environ
.get('CHARM_DIR', os
.getcwd())
19 layer_file
= os
.path
.join(base_dir
, 'layer.yaml')
21 return LayerOptions(layer_file
, section
)