def get_yaml(path):
 single = re.compile('^\\$\\{(.*)\\}$')
 yaml.add_implicit_resolver('!single', single)
 def single_constructor(loader, node):
  value = loader.construct_scalar(node)
  proto = single.match(value).group(1)
  default = None
  if (len(proto.split(':')) > 1):
   (envvar, default) = proto.split(':')
  else:
   envvar = proto
  return (os.environ[envvar] if (envvar in os.environ) else default)
 yaml.add_constructor('!single', single_constructor)
 raw = read_file(path)
 try:
  cfg = yaml.load(raw)
 except yaml.scanner.ScannerError as e:
  raise ConfigurationError('Unable to parse YAML file. Error: {0}'.format(e))
 return cfg

def get_yaml ( path ) : single = re . compile ( '^\\$\\{(.*)\\}$' ) yaml . add_implicit_resolver ( '!single' , single ) def single_constructor ( loader , node ) : value = loader . construct_scalar ( node ) proto = single . match ( value ) . group ( 1 ) default = None if ( len ( proto . split ( ':' ) ) > 1 ) : ( envvar , default ) = proto . split ( ':' ) else : envvar = proto return ( os . environ [ envvar ] if ( envvar in os . environ ) else default ) yaml . add_constructor ( '!single' , single_constructor ) raw = read_file ( path ) try : cfg = yaml . load ( raw ) except yaml . scanner . ScannerError as e : raise ConfigurationError ( 'Unable to parse YAML file. Error: {0}' . format ( e ) ) return cfg
read the file identified by path and import its yaml contents .