Finds all source files that actually exists from a list of file names.

        :param list[str] file_names: The list of file names.
430216
def find_source_files_from_list(self, file_names):
        
        for file_name in file_names:
            if os.path.exists(file_name):
                routine_name = os.path.splitext(os.path.basename(file_name))[0]
                if routine_name not in self._source_file_names:
                    self._source_file_names[routine_name] = file_name
                else:
                    self._io.error("Files '{0}' and '{1}' have the same basename.".
                                   format(self._source_file_names[routine_name], file_name))
                    self.error_file_names.add(file_name)
            else:
                self._io.error("File not exists: '{0}'".format(file_name))
                self.error_file_names.add(file_name)
422883
def expand_file_names(path, files_root):
    
    # For non-wildcards just return the path. This allows us to detect when
    # explicitly listed files are missing.
    if not any(wildcard in path for wildcard in '*?['):
        return [path]
    else:
        dir_path, filename = os.path.split(path)
        return [os.path.join(dir_path, f) for f in fnmatch.filter(os.listdir(os.path.join(files_root, dir_path)), filename)]
1220882
def _search_for_files(parts):
    
    file_parts = []
    for part in parts:
        if isinstance(part, list):
            file_parts.extend(_search_for_files(part))
        elif isinstance(part, FileToken):
            file_parts.append(part)
    return file_parts
1269622
def file_list( files )
    case files
    when String
      [files]
    when Array
      files
    when Proc
      files.call # result should respond to #each
    else
      []
    end
  end
324629
def sources(file_name)
      files =
        if File.directory?(file_name)
          Dir.glob(File.join(file_name, '**/*.rb')).sort
        elsif File.file?(file_name)
          [file_name]
        else
          Dir.glob(file_name).sort
        end

      files.map(&Source::File.method(:new))
    end
782644
def listFiles(self):
        
        def fn(dirName, level, files):
            if level == self.levelNo-1:
                for fileName in os.listdir(dirName):
                    if fileName != "lock":
                        absFileName = os.path.join(dirName, fileName)
                        files.append(absFileName)
            else:
                for subDir in os.listdir(dirName):
                    if subDir != "lock":
                        absDirName = os.path.join(dirName, subDir)
                        assert os.path.isdir(absDirName)
                        fn(absDirName, level+1, files)
        files = []
        fn(self.rootDir, 0, files)
        return files
412326
def list_files(dirname, extension=None):
    
    f = []
    for (dirpath, dirnames, filenames) in os.walk(dirname):
        f.extend(filenames)
        break
    if extension is not None:
        # Filter on extension
        filtered = []
        for filename in f:
            fn, ext = os.path.splitext(filename)
            if ext.lower() == '.' + extension.lower():
                filtered.append(filename)
        f = filtered
    return f
714189
def _check_file_existence(self, files):
        ''''''
        for f in files:
            if not os.path.isfile(f):
                logging.error("The file '%s' does not appear to exist, stopping" % f)
                exit(1)
493808
def files
      return [] unless path.exist? && path.directory? && !includes.empty?

      Pathname.glob(%(#{path}/{#{includes.join ","}})).select(&:file?)
    end
801673
def find_files_for_use(self, all_files):
        
        for path in all_files:
            # Find the path relative to the parent dir
            relpath = self.relpath_for(path)

            # Don't care about the ./
            if relpath.startswith("./"):
                relpath = relpath[2:]

            # Only care about paths that aren't filtered
            if not self.is_filtered(relpath):
                yield Path(path, relpath)
931801
private function findSourceFiles(): void
  {
    $helper    = new SourceFinderHelper(dirname($this->configFilename));
    $filenames = $helper->findSources($this->sourcePattern);

    foreach ($filenames as $filename)
    {
      $routineName     = pathinfo($filename, PATHINFO_FILENAME);
      $this->sources[] = ['path_name'    => $filename,
                          'routine_name' => $routineName,
                          'method_name'  => $this->methodName($routineName)];
    }
  }
196925
def file_names(self) -> Iterable[str]:
        
        if self.is_sharded():
            yield from ShardedFile(self.filename_spec).get_filenames()
        elif self.filename_spec:
            yield self.filename_spec
1082095
def _visit_pyfiles(list, dirname, names):
    """"""
    # get extension for python source files
    if not globals().has_key('_py_ext'):
        global _py_ext
#        _py_ext = [triple[0] for triple in imp.get_suffixes()
#                   if triple[2] == imp.PY_SOURCE][0]
        _py_ext = [triple[0] for triple in imp.get_suffixes()
                   if triple[2] == imp.PY_SOURCE]
        
    # don't recurse into CVS directories
    if 'CVS' in names:
        names.remove('CVS')

    if '.svn' in names:
        names.remove('.svn')

    if '.git' in names:
        names.remove('.git')

    if 'static' in names:
        names.remove('static')
    
    # add all *.py files to list
    list.extend(
        [os.path.join(dirname, file) for file in names
         if os.path.splitext(file)[1] in _py_ext]
        )
1367821
def list_files(self, project_name):
        
        project = self._get_project_for_name(project_name)
        file_path_dict = self._get_file_path_dict_for_project(project)
        return list(file_path_dict)
1347444
def contains_python_files_or_subdirs(folder):
    
    for root, dirs, files in os.walk(folder):
        if [filename for filename in files if filename.endswith('.py') or filename.endswith('.pyc')]:
            return True

        for d in dirs:
            for _, subdirs, subfiles in os.walk(d):
                if [filename for filename in subfiles if filename.endswith('.py') or filename.endswith('.pyc')]:
                    return True

    return False
628541
async def get_files_to_delete(self) -> List[str]:
        
        dir_name, base_name = os.path.split(self.absolute_file_path)
        file_names = await self.loop.run_in_executor(
            None, lambda: os.listdir(dir_name)
        )
        result = []
        prefix = base_name + "."
        plen = len(prefix)
        for file_name in file_names:
            if file_name[:plen] == prefix:
                suffix = file_name[plen:]
                if self.ext_match.match(suffix):
                    result.append(os.path.join(dir_name, file_name))
        if len(result) < self.backup_count:
            return []
        else:
            return result[: len(result) - self.backup_count]
429775
def find_files(self):
        ''''''
        for path in self.paths:
            for subpath, dirs, files in os.walk(path):
                for filename in files:
                    (name, ext) = os.path.splitext(filename)
                    if ext in self.extensions:
                        yield os.path.join(subpath, filename)