Glob a filename or list of filenames but always return the original
    string if the glob didn't match anything so URLs for remote file access
    are not clobbered.
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
549908
def strip_glob(string, split_str=' '):
    
    string = _GLOB_PORTION_RE.sub(split_str, string)
    return string.strip()
758838
def globlookup(pattern, root):
    
    for subdir, dirnames, filenames in os.walk(root):
        d = subdir[len(root) + 1:]
        files = (os.path.join(d, f) for f in filenames)
        for f in fnmatch.filter(files, pattern):
            yield f
47018
def super_glob(pattern):
    ''
    pieces = pattern.split('/')
    if '**' in pieces:
        prefix = '/'.join(pieces[:pieces.index('**')])
        postfix = '/'.join(pieces[pieces.index('**') + 1:])
        roots = [dirname
                 for dirname, dirnames, filenames in os.walk(prefix)]
        patterns = [root + '/' + postfix for root in roots]
    else:
        patterns = ['/'.join(pieces)]
    return chain.from_iterable(glob(pattern) for pattern in patterns)
886170
def find_all_files(glob):
    
    for finder in finders.get_finders():
        for path, storage in finder.list([]):
            if fnmatch.fnmatchcase(os.path.join(getattr(storage, 'prefix', '')
                                                or '', path),
                                   glob):
                yield path, storage
903604
def _urlretrieve(url, filename):
    
    ctx = create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = CERT_NONE

    with urlopen(url, context=ctx) as u, filename.open('wb') as f:
            f.write(u.read())
1081854
def __getFilenameSuffix(self, filename):
        """"""
        if filename and isinstance(filename, string_types):
            if self.__isValidTGZ(filename):
                return ".tar.gz"
            elif filename.endswith(".zip"):
                return ".zip"
123644
def files_exist(self, filenames):
        
        return all([os.path.exists(os.path.abspath(filename)) and os.path.isfile(os.path.abspath(filename))
                    for filename in filenames])
767182
def filename_match(filename, patterns, default=True):
    
    if not patterns:
        return default
    return any(fnmatch(filename, pattern) for pattern in patterns)
1017263
def retrieve_files():
    

    all_files = []
    for location in cfg.CONF.locations or []:
        # if local path then make sure it is absolute
        if not location.startswith('\\'):
            location = os.path.abspath(os.path.expanduser(location))

        LOG.debug('searching [%s]', location)
        for root, _, files in os.walk(location):
            LOG.debug('found file(s) %s', files)
            for name in files:
                filepath = os.path.join(root, name)
                if (os.access(filepath, os.R_OK) and
                        not _is_blacklisted_filename(filepath) and
                        _is_valid_extension(os.path.splitext(name)[1])):
                    all_files.append(filepath)

    return all_files
619571
def get_file_name(url):
  """"""
  return os.path.basename(urllib.parse.urlparse(url).path) or 'unknown_name'
192750
def _find_glob_matches(in_files, metadata):
    
    reg_files = copy.deepcopy(in_files)
    glob_files = []
    for glob_search in [x for x in metadata.keys() if "*" in x]:
        cur = []
        for fname in in_files:
            if fnmatch.fnmatch(fname, "*/%s" % glob_search):
                cur.append(fname)
                reg_files.remove(fname)
        assert cur, "Did not find file matches for %s" % glob_search
        glob_files.append(cur)
    return reg_files, glob_files
1058591
def filename_match(filename):
    
    if not options.filename:
        return True
    for pattern in options.filename:
        if fnmatch(filename, pattern):
            return True
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
1248504
def changed(self, filename='.md5', glob=None):
        
        if glob is not None:
            filename += '.glob-' + ''.join(ch.lower()
                                           for ch in glob if ch.isalpha())
        return changed(self, filename, glob=glob)
648471
def glob_files(glob)
      absolute = 
      paths = if Pathname.new(glob).absolute?
        Dir[glob].sort
      else
        search_paths = (Jammit.asset_roots).map{ |path| File.join(path, glob) }
        Dir[*search_paths].sort
      end
      Jammit.warn("No assets match '#{glob}'") if paths.empty?
      paths
    end
949754
def existing_versions(self):
        
        import glob
        pattern = self.fname + '_*' + self.ext
        for fname in glob.glob1(self.dpath, pattern):
            fpath = join(self.dpath, fname)
            yield fpath