def open_json_or_yml(file_name):
 try:
  import json
  json_file = '{0}.json'.format(*os.path.splitext(file_name))
  with open(json_file, 'r') as f:
   return json.load(f)
 except IOError:
  import yaml
  yml_file = '{0}.yml'.format(*os.path.splitext(file_name))
  with open(yml_file, 'r') as f:
   return yaml.load(f)

def open_json_or_yml ( file_name ) : try : import json json_file = '{0}.json' . format ( * os . path . splitext ( file_name ) ) with open ( json_file , 'r' ) as f : return json . load ( f ) except IOError : import yaml yml_file = '{0}.yml' . format ( * os . path . splitext ( file_name ) ) with open ( yml_file , 'r' ) as f : return yaml . load ( f )
try to load either the json or yaml version of a file .