def should_check_directory(directory_path, exclude_patterns, include_patterns):
 def normalize_path(path):
  return path.replace(os.path.sep, '/')
 path_with_slash = (normalize_path(directory_path) + '/')
 possible_child_patterns = [pattern for pattern in map(normalize_path, include_patterns) if (pattern + '/').startswith(path_with_slash)]
 directory_included = should_include(directory_path, exclude_patterns, include_patterns)
 return (directory_included or (len(possible_child_patterns) > 0))

def should_check_directory ( directory_path , exclude_patterns , include_patterns ) : def normalize_path ( path ) : return path . replace ( os . path . sep , '/' ) path_with_slash = ( normalize_path ( directory_path ) + '/' ) possible_child_patterns = [ pattern for pattern in map ( normalize_path , include_patterns ) if ( pattern + '/' ) . startswith ( path_with_slash ) ] directory_included = should_include ( directory_path , exclude_patterns , include_patterns ) return ( directory_included or ( len ( possible_child_patterns ) > 0 ) )
given a directory path .