def is_a_yaml_with_class(path, classes):
 if (not _has_extension(path, YAML_EXTENSIONS)):
  return False
 with open(path, 'r') as f:
  try:
   as_dict = yaml.safe_load(f)
  except Exception:
   return False
 if (not isinstance(as_dict, dict)):
  return False
 file_class = as_dict.get('class', None)
 return (file_class in classes)

def is_a_yaml_with_class ( path , classes ) : if ( not _has_extension ( path , YAML_EXTENSIONS ) ) : return False with open ( path , 'r' ) as f : try : as_dict = yaml . safe_load ( f ) except Exception : return False if ( not isinstance ( as_dict , dict ) ) : return False file_class = as_dict . get ( 'class' , None ) return ( file_class in classes )
determine if a file is a valid yaml with a supplied class entry .