Returns a list of file extensions from the same folder as file_name.
169517
def extensions_in_same_folder(file_name):
    """"""

    directory = os.path.dirname(file_name)
    files = os.listdir(directory)
    extensions = list(zip(*map(os.path.splitext, files)))[1]
    extensions = set([ext.lower() for ext in extensions])
    return extensions
754398
def get_python_files(files):
        """"""
        python_files = []
        for file_name in files:
            if file_name.endswith(".py"):
                python_files.append(file_name)

        return python_files
1212931
def list_matching_files(dir, extensions=None, recursive=True):
    
    from .modules import utils
    return utils.list_matching_files(dir, extensions=extensions, recursive=recursive)
217136
public Collection<File> getResources(List<String> extensions) {
        List<File> files = new ArrayList<>();
        files.addAll(WatcherUtils.getAllFilesFromDirectory(getInternalAssetsDirectory(), extensions));
        files.addAll(WatcherUtils.getAllFilesFromDirectory(getExternalAssetsDirectory(), extensions));
        return files;
    }
19999
def list_files(directory):
    '''
    
    '''
    ret = set()
    ret.add(directory)
    for root, dirs, files in safe_walk(directory):
        for name in files:
            ret.add(os.path.join(root, name))
        for name in dirs:
            ret.add(os.path.join(root, name))

    return list(ret)
940497
def ListFiles(self, ext_attrs=False):
    """"""
    if not self.IsDirectory():
      raise IOError("%s is not a directory." % self.path)

    for path in self.files:
      try:
        filepath = utils.JoinPath(self.path, path)
        response = self._Stat(filepath, ext_attrs=ext_attrs)
        pathspec = self.pathspec.Copy()
        pathspec.last.path = utils.JoinPath(pathspec.last.path, path)
        response.pathspec = pathspec

        yield response
      except OSError:
        pass
88853
def load_files(file_finder)
      if file_finder.options.fetch(:files).empty?
        file_finder.list(*options[:extensions])
      else
        file_finder.options.fetch(:files) { [] }
      end
    end
722382
public function getFilesInDir($dir_path, array $file_extensions)
    {
        $file_paths = [];

        /** @var \RecursiveDirectoryIterator */
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir_path));
        $iterator->rewind();

        while ($iterator->valid()) {
            if (!$iterator->isDot()) {
                $extension = $iterator->getExtension();
                if (in_array($extension, $file_extensions, true)) {
                    $file_paths[] = (string)$iterator->getRealPath();
                }
            }

            $iterator->next();
        }

        return $file_paths;
    }
186088
def files_with_exts(root='.', suffix=''):
    
    return (os.path.join(rootdir, filename)
            for rootdir, dirnames, filenames in os.walk(root)
            for filename in filenames
            if filename.endswith(suffix))
71604
def recursively_get_files_from_directory(directory):
    
    return [
        os.path.join(root, filename)
        for root, directories, filenames in os.walk(directory)
        for filename in filenames
    ]
527043
def get_filenames_in_lipd(path, name=""):
    
    _filenames = []
    try:
        # in the top level, list all files and skip the "data" directory
        _top = [os.path.join(name, f) for f in os.listdir(path) if f != "data"]
        # in the data directory, list all files
        _dir_data = [os.path.join(name, "data", f) for f in os.listdir(os.path.join(path, "data"))]
        # combine the two lists
        _filenames = _top + _dir_data
    except Exception:
        pass
    return _filenames
974776
def extract_files(files):
    """"""
    expanded_files = []
    legal_extensions = [".md", ".txt", ".rtf", ".html", ".tex", ".markdown"]

    for f in files:
        # If it's a directory, recursively walk through it and find the files.
        if os.path.isdir(f):
            for dir_, _, filenames in os.walk(f):
                for filename in filenames:
                    fn, file_extension = os.path.splitext(filename)
                    if file_extension in legal_extensions:
                        joined_file = os.path.join(dir_, filename)
                        expanded_files.append(joined_file)

        # Otherwise add the file directly.
        else:
            expanded_files.append(f)

    return expanded_files
259804
def get_file_extension_type(filename):
    
    ext = get_file_extension(filename)
    if ext:
        for name, group in EXTENSIONS.items():
            if ext in group:
                return name
    return "OTHER"
189583
public static List<File> listFileWithExtension(final File rootDir, final String extension) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new FileExtensionFilter(extension)).toList();
	}
59383
def file_extension(path):
    
    if path is None:
        return None
    ext = os.path.splitext(os.path.basename(path))[1]
    if ext.startswith("."):
        ext = ext[1:]
    return ext
499312
def expand_filenames(self, filenames):
        
        results = []
        for filename in filenames:
            result = filename
            if "$" in filename:
                template = Template(filename)
                result = template.substitute(**self.environment)
                logging.debug(
                    "Expanding {} to {}.".format(filename, result))
            if any([pattern in result for pattern in "*[]?"]):
                expanded = glob.glob(result)
                if len(expanded) > 0:
                    result = expanded
                else:
                    result = "NONEXISTENT"
            if isinstance(result, list):
                results.extend(result)
            else:
                results.append(result)
        return sorted(list(set(results)))
473997
def from_folder(cls, path:PathOrStr, extensions:Collection[str]=None, recurse:bool=True,
                    include:Optional[Collection[str]]=None, processor:PreProcessors=None, **kwargs)->'ItemList':
        """"""
        path = Path(path)
        return cls(get_files(path, extensions, recurse=recurse, include=include), path=path, processor=processor, **kwargs)