Delete files within ``directory`` whose filename *exactly* matches one of
    ``filenames``.
174075
def delete_files_within_dir(directory: str, filenames: List[str]) -> None:
    
    for dirpath, dirnames, fnames in os.walk(directory):
        for f in fnames:
            if f in filenames:
                fullpath = os.path.join(dirpath, f)
                log.debug("Deleting {!r}", fullpath)
                os.remove(fullpath)
1034216
def remove_dirs(self, directory):
        

        LOG.info('Removing directory [ %s ]', directory)
        local_files = self._drectory_local_files(directory=directory)
        for file_name in local_files:
            try:
                os.remove(file_name['local_object'])
            except OSError as exp:
                LOG.error(str(exp))

        # Build a list of all local directories
        directories = sorted(
            [i for i, _, _ in os.walk(directory)],
            reverse=True
        )

        # Remove directories
        for directory_path in directories:
            try:
                os.removedirs(directory_path)
            except OSError as exp:
                if exp.errno != 2:
                    LOG.error(str(exp))
                pass
1024047
def remove_files(self, *filenames):
        """"""
        filenames = list_strings(filenames)

        for dirpath, dirnames, fnames in os.walk(self.workdir):
            for fname in fnames:
                if fname in filenames:
                    filepath = os.path.join(dirpath, fname)
                    os.remove(filepath)
1333097
def clear_dir(path):
    """"""
    for f in os.listdir(path):
        f_path = os.path.join(path, f)
        if os.path.isfile(f_path) or os.path.islink(f_path):
            os.unlink(f_path)
677218
def rmdir(self, dir_name):
        """"""
        self.check_write(dir_name)
        path = normpath_url(join_url(self.cur_dir, dir_name))
        # write("REMOVE %r" % path)
        shutil.rmtree(path)
1277104
def rm_files(path, extension):
    
    files = list_files(extension, path)
    for file in files:
        if file.endswith(extension):
            os.remove(os.path.join(path, file))
    return
75985
def recursive_pattern_delete(root, file_patterns, directory_patterns, dry_run=False):
    """"""
    for root, dirs, files in os.walk(root):
        for pattern in file_patterns:
            for file_name in fnmatch.filter(files, pattern):
                file_path = os.path.join(root, file_name)
                if dry_run:
                    print_('Removing {}'.format(file_path))
                    continue
                os.remove(file_path)

        for pattern in directory_patterns:
            for found_dir in fnmatch.filter(dirs, pattern):
                if os.path.exists(found_dir):
                    if dry_run:
                        print('Removing directory tree {}'.format(found_dir))
                        continue
                    shutil.rmtree(found_dir)
427627
def delete_cached_files(self, prefixes=[], suffixes=[]):
        
        for filename in listdir(self.cache_directory_path):
            delete = (
                any([filename.endswith(ext) for ext in suffixes]) or
                any([filename.startswith(pre) for pre in prefixes]))
            if delete:
                path = join(self.cache_directory_path, filename)
                logger.info("Deleting %s", path)
                remove(path)
853459
def directoryRemove(self, dir_key, key):
    '''
    '''
    key = str(key)

    dir_items = self.get(dir_key) or []
    if key in dir_items:
      dir_items = [k for k in dir_items if k != key]
      self.put(dir_key, dir_items)
1030121
def removeFileSafely(filename,clobber=True):
    
    if filename is not None and filename.strip() != '':
        if os.path.exists(filename) and clobber: os.remove(filename)
1290636
def match_files(self, matched, unmatched):
        """"""
        this_match = set(self.file_filter(unmatched))
        matched |= this_match
        unmatched -= this_match
497246
def safe_delete(filename):
  """"""
  try:
    os.unlink(filename)
  except OSError as e:
    if e.errno != errno.ENOENT:
      raise
815817
def remove_file(self, name):
        """"""
        self.check_write(name)
        path = os.path.join(self.cur_dir, name)
        os.remove(path)
197483
def prune(self, dir):
        """"""
        match = translate_pattern(os.path.join(dir, '**'))
        return self._remove_files(match.match)
55725
def remove_files(filename):
        # type: (AnyStr) -> None
        
        pattern = os.path.splitext(filename)[0] + '.*'
        for f in glob.iglob(pattern):
            os.remove(f)
1228608
def remove_files(root_dir):
    
    for dirpath, dirnames, filenames in os.walk(os.path.abspath(root_dir)):
        for filename in filenames:
            os.remove(os.path.join(root_dir, filename))

        for dirname in dirnames:
            shutil.rmtree(os.path.join(root_dir, dirname))
1039048
def match(self, filename, isdir):
    

    fnmatch = _fnmatch.fnmatch
    ignored = False
    filename = self.convert_path(filename)
    basename = os.path.basename(filename)

    for pattern in self.patterns:
      if pattern.dir_only and not isdir:
        continue
      if (not ignored or pattern.invert) and pattern.match(filename):
        if pattern.invert: # This file is definitely NOT ignored, no matter what other patterns match
          return MATCH_INCLUDE
        ignored = True
    if ignored:
      return MATCH_IGNORE
    else:
      return MATCH_DEFAULT