Check if the directory is in the exclude list.

    Note: by having trailing slashes, we avoid common prefix issues, like
          e.g. an exlude "foo" also accidentally excluding "foobar".
546638
def is_excluded(root, excludes):
    # type: (unicode, List[unicode]) -> bool
    
    for exclude in excludes:
        if fnmatch(root, exclude):
            return True
    return False
920124
def is_file_ignored(opts, fname):
    '''
    
    '''
    if opts['file_ignore_regex']:
        for regex in opts['file_ignore_regex']:
            if re.search(regex, fname):
                log.debug(
                    'File matching file_ignore_regex. Skipping: %s',
                    fname
                )
                return True

    if opts['file_ignore_glob']:
        for glob in opts['file_ignore_glob']:
            if fnmatch.fnmatch(fname, glob):
                log.debug(
                    'File matching file_ignore_glob. Skipping: %s',
                    fname
                )
                return True
    return False
676562
def listdir(self, directory_path=None, hidden_files=False):
        
        # Change current directory if a directory path is specified, otherwise use current
        if directory_path:
            self.chdir(directory_path)

        # Exclude hidden files
        if not hidden_files:
            return [path for path in self.session.nlst() if not path.startswith('.')]

        # Include hidden files
        else:
            return self.session.nlst()
721751
public boolean seemsLikeADirectory() {
    int length = path.length();
    return path.isEmpty()
        || path.charAt(length - 1) == SEPARATOR
        || path.endsWith(".") && (length == 1 || path.charAt(length - 2) == SEPARATOR)
        || path.endsWith("..") && (length == 2 || path.charAt(length - 3) == SEPARATOR);
  }
816517
public void addExclude(String exclude) {

        exclude = normalizePath(exclude);
        m_excludes.add(exclude);
        m_allPaths.add(exclude);
    }
1045698
def get_exclude_paths(registry):
    
    # TODO(#63): remove deprecated `skip_validation` setting in v2.0.
    regexes = registry.settings.get(
        'pyramid_swagger.skip_validation',
        registry.settings.get(
            'pyramid_swagger.exclude_paths',
            DEFAULT_EXCLUDED_PATHS
        )
    )

    # being nice to users using strings :p
    if not isinstance(regexes, list) and not isinstance(regexes, tuple):
        regexes = [regexes]

    return [re.compile(r) for r in regexes]
739532
def has_subdirectories(path, include, exclude, show_all):
    """"""
    try:
        # > 1 because of '..'
        return len( listdir(path, include, exclude,
                            show_all, folders_only=True) ) > 1
    except (IOError, OSError):
        return False
377618
public static function list_dir( $root_dir, $subdirs = true, $allow = '*', $exclude = array(), &$all_files = array(), $level = 1 ){
		$files = @scandir( $root_dir );
		$exclude = array_unique( array_merge( (array) $exclude, array( '.', '..' ) ) );
		if( ! is_array( $files ) ){
			return $all_files;
		}
		foreach ( $files as $key => $file ) {
			$extension = self::get_file_extension( $file );
			$path = $root_dir.'/'.$file;
			//If the file name is on the exclude array
			if( in_array( $file, $exclude ) ){
				continue;
			}
			if( is_file( $path ) ){
				//If the current extension is on the exclude extensions
				if( in_array( '.'.$extension, $exclude ) ){
					continue;
				}
				//If the current extension is not in the list of allowed extensions
				if( $allow != '*' && is_array( $allow ) && ! in_array( '.'.$extension, $allow ) ){
					continue;
				}

				if( file_exists( $path ) ){
					$all_files['files'][] = $path;

					$namespace_key = str_replace( self::dirname_r( $path, $level ), '', $root_dir );
					$namespace_key = trim( $namespace_key, '/ \\');
					$namespace_key = str_replace( array(' ', '/', '\\' ), array( '', '>', '>' ), $namespace_key );
					$file_name = pathinfo( $file, PATHINFO_FILENAME );
					if( empty( $namespace_key ) ){
						$namespace_key = '>';
					}
					$all_files['folders'][$namespace_key][$file_name] = $path;
				}
			} else if( $subdirs && is_dir( $path ) && file_exists( $path ) ){
				$level += 1;
				$all_files = self::list_dir( $path, $subdirs, $allow, $exclude, $all_files, $level );
				$level--;
			}
		}
		return $all_files;
	}
37573
def recursive_exclude(self, dir, pattern):
        
        match = translate_pattern(os.path.join(dir, '**', pattern))
        return self._remove_files(match.match)
1335659
def normalize_excludes(rootpath, excludes):
    
    sep = os.path.sep
    f_excludes = []
    for exclude in excludes:
        if not os.path.isabs(exclude) and not exclude.startswith(rootpath):
            exclude = os.path.join(rootpath, exclude)
        if not exclude.endswith(sep):
            exclude += sep
        f_excludes.append(exclude)
    return f_excludes
1177434
private boolean shouldExcludeSourceFile(CompilationUnitTree tree) {
    Pattern excludedPattern = errorProneOptions.getExcludedPattern();
    return excludedPattern != null
        && excludedPattern.matcher(ASTHelpers.getFileName(tree)).matches();
  }
1266290
def excluded(filename):
    
    basename = os.path.basename(filename)
    for pattern in options.exclude:
        if fnmatch(basename, pattern):
            # print basename, 'excluded because it matches', pattern
            return True
34161
@SuppressWarnings("deprecation")
  private boolean isNamespace(Path dir) throws IOException {
    FileStatus[] stats = rootFileSystem.listStatus(dir, PathFilters.notHidden());
    for (FileStatus stat : stats) {
      if (stat.isDir() && isDataset(stat.getPath())) {
        return true;
      }
    }
    return false;
  }
457141
function globsToExcludeFromFileSet (dirname, fileset) {
  if (fileset.excludes && fileset.excludes.length) {
    return fileset.excludes.map(exclude => '!' + path.join(dirname, exclude));
  } else {
    return [];
  }
}
132486
def is_excluded_path(args, filepath):
    """"""
    # Try regular expressions first.
    for regexp_exclude_path in args.regexp:
        if re.match(regexp_exclude_path, filepath):
            return True
    abspath = os.path.abspath(filepath)
    if args.include:
        # If the file is outside of any include directories.
        out_of_include_dirs = True
        for incl_path in args.include:
            absolute_include_path = os.path.abspath(os.path.join(args.root, incl_path))
            if is_child_dir(absolute_include_path, abspath):
                out_of_include_dirs = False
                break
        if out_of_include_dirs:
            return True

    excl_rules = create_exclude_rules(args)
    for i, rule in enumerate(excl_rules):
        if rule[0] == abspath:
            return rule[1]
        if is_child_dir(rule[0], abspath):
            # continue to try to longest match.
            last_result = rule[1]
            for j in range(i + 1, len(excl_rules)):
                rule_deep = excl_rules[j]
                if not is_child_dir(rule_deep[0], abspath):
                    break
                last_result = rule_deep[1]
            return last_result
    return False
51060
private static boolean isIndexable(String filename, List<String> includes, List<String> excludes) {
        boolean excluded = isExcluded(filename, excludes);
        if (excluded) return false;

        return isIncluded(filename, includes);
    }
623
def _check_open_dir(self, fs, path, info):
        # type: (FS, Text, Info) -> bool
        
        if self.exclude_dirs is not None and fs.match(self.exclude_dirs, info.name):
            return False
        if self.filter_dirs is not None and not fs.match(self.filter_dirs, info.name):
            return False
        return self.check_open_dir(fs, path, info)