def _parse_template(tmpl_str):
 tmpl_str = tmpl_str.strip()
 if tmpl_str.startswith('{'):
  tpl = json.loads(tmpl_str)
 else:
  try:
   tpl = yaml.load(tmpl_str, Loader=YamlLoader)
  except yaml.YAMLError:
   try:
    tpl = yaml.load(tmpl_str, Loader=yaml.SafeLoader)
   except yaml.YAMLError as yea:
    raise ValueError(yea)
  else:
   if (tpl is None):
    tpl = {}
 if (not (('HeatTemplateFormatVersion' in tpl) or ('heat_template_version' in tpl) or ('AWSTemplateFormatVersion' in tpl))):
  raise ValueError('Template format version not found.')
 return tpl

def _parse_template ( tmpl_str ) : tmpl_str = tmpl_str . strip ( ) if tmpl_str . startswith ( '{' ) : tpl = json . loads ( tmpl_str ) else : try : tpl = yaml . load ( tmpl_str , Loader = YamlLoader ) except yaml . YAMLError : try : tpl = yaml . load ( tmpl_str , Loader = yaml . SafeLoader ) except yaml . YAMLError as yea : raise ValueError ( yea ) else : if ( tpl is None ) : tpl = { } if ( not ( ( 'HeatTemplateFormatVersion' in tpl ) or ( 'heat_template_version' in tpl ) or ( 'AWSTemplateFormatVersion' in tpl ) ) ) : raise ValueError ( 'Template format version not found.' ) return tpl
parsing template .