Implementation of `make_glob_patterns()` which only allows a single base directory.
544426
def globs_in_single_dir(cls, spec_dir_path, address_mapper):
    """"""
    return [os.path.join(spec_dir_path, pat) for pat in address_mapper.build_patterns]
1307256
private static Pattern globToRegexp(String glob) {
        final Pattern globToRegexpPattern = Pattern.compile("(\\*\\*)|(\\*)");
        final Matcher matcher = globToRegexpPattern.matcher(glob);
        final StringBuffer sb = new StringBuffer();
        int lastEnd = 0;
        while (matcher.find()) {
            sb.append(Pattern.quote(glob.substring(lastEnd, matcher.start())));
            if (matcher.group(1) != null) {
                sb.append(Matcher.quoteReplacement(".*"));
            }
            if (matcher.group(2) != null) {
                sb.append(Matcher.quoteReplacement("[^.$]*"));
            }
            lastEnd = matcher.end();
        }
        sb.append(Pattern.quote(glob.substring(lastEnd, glob.length())));
        return Pattern.compile(sb.toString());
    }
1104467
def globfilter(filenames, patterns, *, flags=0):
    """"""

    matches = []

    flags = _flag_transform(flags)
    unix = _wcparse.is_unix_style(flags)
    obj = _wcparse.compile(_wcparse.split(patterns, flags), flags)

    for filename in filenames:
        if not unix:
            filename = util.norm_slash(filename)
        if obj.match(filename):
            matches.append(filename)
    return matches
1144647
def Glob(self, pathname, ondisk=True, source=True, strings=False, exclude=None, cwd=None):
        
        if cwd is None:
            cwd = self.getcwd()
        return cwd.glob(pathname, ondisk, source, strings, exclude)
918381
def glob(self):
		
		matches = []
		for root, dirnames, filenames in os.walk(self.path):
			if not self.recursive:
				while len(dirnames) > 0:
					dirnames.pop()
			for include in self.include:
				for filename in fnmatch.filter(filenames, include):
					matches.append(os.path.join(root, filename))
		return matches
1215903
private function patternHasMatch($globPattern)
    {
        if (substr(trim($globPattern), 0, 1) === '/') {
            $globPattern = trim(substr($globPattern, 1));
        } elseif (substr(trim($globPattern), -1) === '/') {
            $globPattern = trim(substr($globPattern, 0, -1));
        } else {
            $globPattern = '{' . trim($globPattern) . '}*';
        }

        $initialWorkingDirectory = (string) getcwd();
        chdir($this->directory);

        $matches = glob($globPattern, GLOB_BRACE);

        chdir($initialWorkingDirectory);

        return is_array($matches) && count($matches) > 0;
    }
642943
def schema_files():
    '''
    '''
    def recursive_glob(path, patterns):
        results = []
        for base, dirs, files in os.walk(path):
            matching_files = []
            for pattern in patterns:
                matching_files.extend(fnmatch.filter(files, pattern))
            results.extend(os.path.join(base, f) for f in matching_files)
        return results

    base_folder = 'datapackage_registry'
    remove_base_folder = lambda path: path[len(base_folder) + 1:]

    path = os.path.join(base_folder, 'schemas')
    files_paths = recursive_glob(path, ['*.csv', '*.json'])

    return [remove_base_folder(f) for f in files_paths]
973464
def _find_files(directory):
    
    pattern = "{directory}/*.xml".format(
        directory=directory,
    )
    files = glob(pattern)
    return files
1367987
function globWithPromsie(pattern) {
  return new Promise((resolve, reject) => {
    glob(pattern, function(err, files) {
      if (err) {
        reject(err);
      }

      if (files.length === 0) {
        console.warn('pattern "' + pattern + '" does not match any file');
      }

      resolve(files);
    });
  });
}
699777
def _glob_to_re(self, pattern):
        
        pattern_re = fnmatch.translate(pattern)

        # '?' and '*' in the glob pattern become '.' and '.*' in the RE, which
        # IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix,
        # and by extension they shouldn't match such "special characters" under
        # any OS.  So change all non-escaped dots in the RE to match any
        # character except the special characters (currently: just os.sep).
        sep = os.sep
        if os.sep == '\\':
            # we're using a regex to manipulate a regex, so we need
            # to escape the backslash twice
            sep = r'\\\\'
        escaped = r'\1[^%s]' % sep
        pattern_re = re.sub(r'((?<!\\)(\\\\)*)\.', escaped, pattern_re)
        return pattern_re
878240
function (directory) {
        // Globs match root level only
        var extMatches = glob.sync(this.getExtensionGlob(this.getExtensions(), ROOT_ONLY), {cwd: directory}),
            dirMatches = glob.sync(this.getDirectoryGlob(this.getDirectories(), ROOT_ONLY), {cwd: directory}),
            extMatchesAll;

        // There is no base directory
        if (extMatches.length > 0 || dirMatches.length > 0) {
            return;
        }
        // There is a base directory, grab it from any ext match
        extMatchesAll = glob.sync(
            this.getExtensionGlob(this.getExtensions(), ALL_DIRS), {cwd: directory}
        );
        if (extMatchesAll.length < 1 || extMatchesAll[0].split('/') < 1) {
            throw new common.errors.ValidationError({message: common.i18n.t('errors.data.importer.index.invalidZipFileBaseDirectory')});
        }

        return extMatchesAll[0].split('/')[0];
    }
1211097
def expand_filename_pattern(pattern, base_dir):
    
    # 'join' ignores base_dir, if expandedPattern is absolute.
    # 'normpath' replaces 'A/foo/../B' with 'A/B', for pretty printing only
    pattern = os.path.normpath(os.path.join(base_dir, pattern))

    # expand tilde and variables
    pattern = os.path.expandvars(os.path.expanduser(pattern))

    # expand wildcards
    fileList = glob.glob(pattern)

    return fileList
1208831
def resolve_pattern(pattern):
    ''''''
    if os.path.exists(pattern) and os.path.isdir(pattern):
        pattern = os.path.join(pattern, '**/*.bench.py')
    return recursive_glob(pattern)
1333580
public function globRecursive($pattern, $flags = 0)
    {
        $maxDepth = $this->maxDepth();
        $depthKey = strval($maxDepth);

        if (isset(static::$globCache[$pattern][$depthKey])) {
            return static::$globCache[$pattern][$depthKey];
        }

        $depth = 1;
        $files = glob($pattern, $flags);
        foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
            $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
            $depth++;
            if ($maxDepth > 0 && $depth >= $maxDepth) {
                break;
            }
        }

        static::$globCache[$pattern][$depthKey] = array_filter($files, 'is_file');

        return $files;
    }
1237169
def globber(main_method, globs):
    """"""
    import os
    from glob import glob

    def main(arguments):
        lists_of_paths = [_ for _ in arguments if glob(pathname, recursive=True)]
        return main_method(arguments, lists_of_paths)
    return main
437574
def glob_by_extensions(directory, extensions):
    
    directorycheck(directory)
    files = []
    xt = files.extend
    for ex in extensions:
        xt(glob.glob('{0}/*.{1}'.format(directory, ex)))
    return files
138597
def _expand_glob_path(file_roots):
    '''
    
    '''
    unglobbed_path = []
    for path in file_roots:
        try:
            if glob.has_magic(path):
                unglobbed_path.extend(glob.glob(path))
            else:
                unglobbed_path.append(path)
        except Exception:
            unglobbed_path.append(path)
    return unglobbed_path