Scans the filenames (keys) and uses fnmatch to find maches
557724
def find(pattern)
      patterns= [pattern].flatten
      contents=[]
      self.each_pair do |path, content|
        patterns.each do |pattern|
          contents << content if Content.path_match? path, pattern
        end
      end
      contents
    end
662435
function dumpFiles(title, fn) {
            var matches = fn();
            if (matches.length) {
                log.info("");
                log.info((title + ":")['green']);
                for (var i = 0; i < matches.length; i++) {
                    if (matches[i].src === matches[i].dst) {
                        log.info(matches[i].dst);
                    } else {
                        log.info(matches[i].dst + ' (from ' + matches[i].src + ')');
                    }
                }
            }
        }
353888
def _glob(filenames):
    
    if isinstance(filenames, string_types):
        filenames = [filenames]
    matches = []
    for name in filenames:
        matched_names = glob(name)
        if not matched_names:
            # use the original string
            matches.append(name)
        else:
            matches.extend(matched_names)
    return matches
1104636
def match_file(self, f, update_file=False):
        
        if self.map_func is not None:
            val = self.map_func(f)
        else:
            m = self.regex.search(f.path)
            val = m.group(1) if m is not None else None

        return self._astype(val)
342686
def matchingfiles(self, projectpath):
        """"""
        results = []

        if projectpath[-1] == '/':
            inputpath = projectpath + 'input/'
        else:
            inputpath = projectpath + '/input/'

        for linkf,realf in clam.common.util.globsymlinks(inputpath + '/.*.INPUTTEMPLATE.' + self.id + '.*'):
            seqnr = int(linkf.split('.')[-1])
            results.append( (seqnr, realf[len(inputpath):], self) )
        results = sorted(results)
        if self.unique and len(results) != 1:
            return []
        else:
            return results
165559
def match(self, filepath):
        
        for pattern in self.__pattern:
            if len(fnmatch.filter([filepath], pattern)) > 0:
                return True
        return False
835946
def matching_files(self):
        
        matching = []
        matcher = self.file_path_regex
        pieces = self.file_path_regex.pattern.split(sep)
        partial_matchers = list(map(re.compile, (
            sep.join(pieces[:i + 1]) for i in range(len(pieces)))))

        for root, dirs, files in walk(self.top_dir, topdown=True):
            for i in reversed(range(len(dirs))):
                dirname = relpath(join(root, dirs[i]), self.top_dir)
                dirlevel = dirname.count(sep)
                if not partial_matchers[dirlevel].match(dirname):
                    del dirs[i]

            for filename in files:
                if matcher.match(filename):
                    matching.append(abspath(join(root, filename)))

        return matching
546573
def match(Class, path, pattern, flags=re.I, sortkey=None, ext=None):
        """"""
        return sorted(
            [
                Class(fn=fn)
                for fn in rglob(path, f"*{ext or ''}")
                if re.search(pattern, os.path.basename(fn), flags=flags) is not None
                and os.path.basename(fn)[0] != '~'  # omit temp files
            ],
            key=sortkey,
        )
916170
function getFileNames(fileNames = [], componentName) {
  const defaultFileNames = {
    testFileName: `${defaultOptions.testFileName}.${componentName}`,
    componentFileName: componentName,
    styleFileName: componentName,
  }

  const formattedFileNames = Object.keys(fileNames).reduce(
    (acc, curr) => {
      acc[curr] = replaceKeys(fileNames[curr], componentName)
      return acc
    },
    { ...defaultFileNames }
  )

  return formattedFileNames
}
504334
def find_macthing_files(match):
    """"""
    last_slash = match.rfind('/')
    if last_slash == -1:
        dirname = '.'
        match_prefix = match
        result_prefix = ''
    else:
        dirname = match[0:last_slash]
        match_prefix = match[last_slash + 1:]
        result_prefix = dirname + '/'
    return [result_prefix + filename for filename in os.listdir(dirname) if filename.startswith(match_prefix)]
921387
def _open_fits_files(filenames):
    
    kw = { 'mode' : 'update', 'memmap' : False }

    def _fh(fn):
        """ Returns a filehandle or None if file does not exist """
        return fits.open(fn, **kw) if os.path.exists(fn) else None

    return collections.OrderedDict(
            (corr, tuple(_fh(fn) for fn in files))
        for corr, files in filenames.iteritems() )
1373271
def filename_items_for_filetype(filenames, filetype_info):
        """"""
        matched_files = []
        for pattern in filetype_info['file_patterns']:
            for filename in match_filenames(filenames, pattern):
                if filename in matched_files:
                    continue
                try:
                    filename_info = parse(
                        pattern, get_filebase(filename, pattern))
                except ValueError:
                    logger.debug("Can't parse %s with %s.", filename, pattern)
                    continue
                matched_files.append(filename)
                yield filename, filename_info
406957
static public void scanRoot(File root,
                                Set<String> suffixes,
                                List<String> excludes,
                                List<String> includes,
                                Map<String,Source> foundFiles,
                                Map<String,Module> foundModules,
                                final Module currentModule,
                                boolean permitSourcesWithoutPackage,
                                boolean inGensrc,
                                boolean inLinksrc)
                                        throws IOException, ProblemException {

        if (root == null)
            return;

        FileSystem fs = root.toPath().getFileSystem();

        if (includes.isEmpty()) {
            includes = Collections.singletonList("**");
        }

        List<PathMatcher> includeMatchers = createPathMatchers(fs, includes);
        List<PathMatcher> excludeMatchers = createPathMatchers(fs, excludes);

        Files.walkFileTree(root.toPath(), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

                Path relToRoot = root.toPath().relativize(file);

                if (includeMatchers.stream().anyMatch(im -> im.matches(relToRoot))
                        && excludeMatchers.stream().noneMatch(em -> em.matches(relToRoot))
                        && suffixes.contains(Util.fileSuffix(file))) {

                    // TODO: Test this.
                    Source existing = foundFiles.get(file);
                    if (existing != null) {
                        throw new IOException("You have already added the file "+file+" from "+existing.file().getPath());
                    }
                    existing = currentModule.lookupSource(file.toString());
                    if (existing != null) {

                            // Oups, the source is already added, could be ok, could be not, lets check.
                            if (inLinksrc) {
                                // So we are collecting sources for linking only.
                                if (existing.isLinkedOnly()) {
                                    // Ouch, this one is also for linking only. Bad.
                                    throw new IOException("You have already added the link only file " + file + " from " + existing.file().getPath());
                                }
                                // Ok, the existing source is to be compiled. Thus this link only is redundant
                                // since all compiled are also linked to. Continue to the next source.
                                // But we need to add the source, so that it will be visible to linking,
                                // if not the multi core compile will fail because a JavaCompiler cannot
                                // find the necessary dependencies for its part of the source.
                                foundFiles.put(file.toString(), existing);
                            } else {
                                // We are looking for sources to compile, if we find an existing to be compiled
                                // source with the same name, it is an internal error, since we must
                                // find the sources to be compiled before we find the sources to be linked to.
                                throw new IOException("Internal error: Double add of file " + file + " from " + existing.file().getPath());
                            }

                    } else {

                        //////////////////////////////////////////////////////////////
                        // Add source
                        Source s = new Source(currentModule, file.toString(), file.toFile());
                        if (inGensrc) {
                            s.markAsGenerated();
                        }
                        if (inLinksrc) {
                            s.markAsLinkedOnly();
                        }
                        String pkg = packageOfJavaFile(root.toPath(), file);
                        pkg = currentModule.name() + ":" + pkg;
                        foundFiles.put(file.toString(), s);
                        currentModule.addSource(pkg, s);
                        //////////////////////////////////////////////////////////////
                    }
                }

                return FileVisitResult.CONTINUE;
            }
        });
    }
1124555
def match_files(files, pattern: Pattern):
    """"""

    for name in files:
        if re.match(pattern, name):
            yield name
1191160
def find(file_pattern, top_dir, max_depth=None, path_pattern=None):
    
    if max_depth:
        base_depth = os.path.dirname(top_dir).count(os.path.sep)
        max_depth += base_depth

    for path, dirlist, filelist in os.walk(top_dir):
        if max_depth and path.count(os.path.sep) >= max_depth:
            del dirlist[:]

        if path_pattern and not fnmatch.fnmatch(path, path_pattern):
            continue

        for name in fnmatch.filter(filelist, file_pattern):
            yield os.path.join(path, name)
1290636
def match_files(self, matched, unmatched):
        """"""
        this_match = set(self.file_filter(unmatched))
        matched |= this_match
        unmatched -= this_match
150547
def [](key)
      file = filename key
      return unless File.exist? file

      File.read(file, encoding: "utf-8")
    end