does a directory search for data files
500031
def _set_data_filelist(self,
                           start_path,
                           attr_name,
                           conn,
                           file_exts=[],
                           dir_filter=set()):
        '''  '''

        def filter_path(filter_terms, dir_path):
            """ sees if any of the terms are present in the path if so returns
                True

            args:
                filter_terms(list): terms to check
                dir_path: the path of the directory
            """
            if filter_terms.intersection(set(dir_path.split(os.path.sep))):
                return True
            else:
                return False

        data_obj = {}
        files_dict = {}
        latest_mod = 0
        dir_filter = set(dir_filter)
        for root, dirnames, filenames in os.walk(start_path):
            if not dir_filter or filter_path(dir_filter, root):
                if file_exts:
                    filenames = [x for x in filenames
                                 if x.split('.')[-1].lower() in file_exts]
                files_dict[root] = filenames
                for def_file in filenames:
                    file_mod = os.path.getmtime(os.path.join(root,def_file))
                    if file_mod > latest_mod:
                        latest_mod = file_mod
        data_obj['latest_mod'] = latest_mod
        data_obj['files'] = files_dict
        json_mod = 0
        cache_path = os.path.join(CFG.CACHE_DATA_PATH, attr_name)
        if cache_path:
            for root, dirnames, filenames in os.walk(cache_path):
                for json_file in filenames:
                    file_mod = os.path.getmtime(os.path.join(root,json_file))
                    if file_mod > json_mod:
                        json_mod = file_mod
        data_obj['last_json_mod'] = json_mod
        data_obj['conn'] = conn
        data_obj['cache_path'] = cache_path
        self.datafile_obj[attr_name] = data_obj
1087227
private void getDescFiles(File dir, Collection<File> files) {
        if (dir.isDirectory()) {
            for (File file : dir.listFiles()) {
                if (file.isDirectory()) {
                    getDescFiles(file, files);
                } else if (file.getName().equals(DESC)) {
                    files.add(file);
                }
            }
        }
    }
1225672
def find(cls, searched_dir, pattern):
        
        Log.debug('find {0} with pattern: {1}'.format(searched_dir, pattern))
        matched_files = []
        for root_dir, dir_names, file_names in os.walk(searched_dir,
                                                       followlinks=False):
            for file_name in file_names:
                if fnmatch.fnmatch(file_name, pattern):
                    file_path = os.path.join(root_dir, file_name)
                    if not os.path.islink(file_path):
                        matched_files.append(file_path)
        matched_files.sort()
        return matched_files
805333
def find_file( self, folder_id, basename, limit = 500 ):
        '''
        
        '''
        search_folder = self.client.folder( folder_id = folder_id )
        offset = 0
        search_items = search_folder.get_items( limit = limit, offset = offset )
        found_files = []
        while len(search_items) > 0:
            files = [ (f['id'], f['name']) for f in search_items if f['name'].startswith( basename ) and f['type'] == 'file' ]
            files.sort()
            for f_id, f_name in files:
                assert(
                    f_name == basename
                    or
                    ( f_name.startswith( basename ) and f_name[len(basename):len(basename)+5] == '.part' )
                )
            found_files.extend( files )
            offset += limit
            search_items = search_folder.get_items( limit = limit, offset = offset )
        return [f[0] for f in found_files]
906189
def find_files(path, filter="*.md"):
        
        if os.path.isfile(path):
            return [path]

        if os.path.isdir(path):
            matches = []
            for root, dirnames, filenames in os.walk(path):
                for filename in fnmatch.filter(filenames, filter):
                    matches.append(os.path.join(root, filename))
            return matches
133852
def find_data(folder):
    
    for (path, directories, filenames) in os.walk(folder):
        for filename in filenames:
            yield os.path.join('..', path, filename)
251060
def _recursive_search_file_in_directory(self, directory, searched_file):
        
        s = os.path.split(searched_file)

        for root, dirs, files in os.walk(directory):
            for file in files:
                # If filename is the same
                if s[1] == file and (s[0] == '' or s[0] == os.path.basename(root)):
                    path = os.path.normpath(os.path.join(root, s[1]))
                    if os.path.exists(path):
                        return path
        return None
237992
public boolean isDirectory() {
        if (this.file != null) {
            return this.file.isDirectory();
        }

        if (this.header != null) {
            if (this.header.linkFlag == TarHeader.LF_DIR) {
                return true;
            }

            if (this.header.name.toString().endsWith("/")) {
                return true;
            }
        }

        return false;
    }
983152
def is_directory (self):
        
        filename = self.get_os_filename()
        return os.path.isdir(filename) and not os.path.islink(filename)
347707
def contains_glob(path_to_directory, pattern, wanted=None):
    """"""
    if not path_to_directory:
        return False
    needed = make_needed(pattern, path_to_directory, wanted)
    for name in _names_in_directory(path_to_directory):
        if needed(name):
            return True
    return False
375555
function isDirectory(filePath) {
  if (!isExist(filePath)) return false;
  try {
    const stat = fs.statSync(filePath);
    return stat.isDirectory();
  } catch (e) {
    return false;
  }
}
660076
private boolean directoryContains(File directory, IGroupMember member) {
        boolean found = false;
        if (member.isGroup()) {
            File memberFile = getFile((IEntityGroup) member);
            File[] files = directory.listFiles();
            for (int i = 0; i < files.length & !found; i++) {
                found = files[i].equals(memberFile);
            }
        }
        return found;
    }
1215007
def isdir(self, dirname):
        """"""
        client = boto3.client("s3")
        bucket, path = self.bucket_and_path(dirname)
        if not path.endswith("/"):
            path += "/"  # This will now only retrieve subdir content
        r = client.list_objects(Bucket=bucket, Prefix=path, Delimiter="/")
        if r.get("Contents") or r.get("CommonPrefixes"):
            return True
        return False
864095
def search_files(directories, extensions)
      extensions.each_with_object([]) do |ext, obj|
        directories.each do |dir|
          obj << FileList["#{dir}/*#{ext}"]
        end
      end.flatten.compact
    end
723165
private boolean searchHarDir(FileStatus stat) 
      throws IOException {
    if (!stat.isDir()) {
      return false;
    }
    String pattern = stat.getPath().toString() + "/*" + RaidNode.HAR_SUFFIX 
        + "*";
    FileStatus[] stats = globStatus(new Path(pattern));
    if (stats != null && stats.length > 0) {
      return true;
    }
      
    stats = fs.listStatus(stat.getPath());
   
    // search deeper.
    for (FileStatus status : stats) {
      if (searchHarDir(status)) {
        return true;
      }
    }
    return false;
  }
1233159
static function searchdir($path,$mode = "FULL",$file_types = array(".html",".php"),$maxdepth = -1,$d = 0) {
	   if(substr($path,strlen($path)-1) != '/')
		   $path .= '/';
	   $dirlist = array();
	   if($mode != "FILES")
			$dirlist[] = $path;
	   if($handle = @opendir($path)) {
		   while(false !== ($file = readdir($handle)))
		   {
			   if($file != '.' && $file != '..')
			   {
				   $file = $path.$file ;
				   if(!is_dir($file))
				   {
						if($mode != "DIRS")
						{
							$extension = "";
							$extpos = strrpos($file, '.');
							if($extpos!==false)
								$extension = substr($file,$extpos,strlen($file)-$extpos);
							$extension=strtolower($extension);
							if(in_array($extension, $file_types))
								$dirlist[] = $file;
						}
				   }
				   elseif($d >= 0 && ($d < $maxdepth || $maxdepth < 0))
				   {
					   $result = self::searchdir($file.'/',$mode,$file_types,$maxdepth,$d + 1) ;
					   $dirlist = array_merge($dirlist,$result);
				   }
			   }
		   }
		   closedir ( $handle ) ;
	   }
	   if($d == 0)
		   natcasesort($dirlist);

	   return($dirlist) ;
	}
438188
def has_dir(state, fname, incorrect_msg="Did you create a directory named `{}`?"):
    """"""
    if not Path(fname).is_dir():
        state.report(Feedback(incorrect_msg.format(fname)))

    return state