remove the source path from the dirname (if it exists)
1754
def digest_dirname(file_path)
      slash_path(File.dirname(file_path)).sub(slash_path(self.source.path), '')
    end
1278323
function cleanup_directory(directory_path, callback) {
  // only remove the folder at directory_path if it exists
  fs.exists(directory_path, function (exists) {
    if (!exists) {
      return callback();
    }
    rimraf(directory_path, callback);
  });
}
1057283
def remove_directories(list_of_paths):
    
    found_dirs = set('/')
    for path in list_of_paths:
        dirs = path.strip().split('/')
        for i in range(2,len(dirs)):
            found_dirs.add( '/'.join(dirs[:i]) )

    paths = [ path for path in list_of_paths if
              (path.strip() not in found_dirs) and path.strip()[-1]!='/' ]
    return paths
933809
def remove_dir(path)
      if File.directory?(path)
        Dir.foreach(path) do |file|
          if ((file.to_s != ".") && (file.to_s != ".."))
            remove_dir("#{path}/#{file}")
          end
        end
        Dir.delete(path)
      else
        File.delete(path)
      end
    end
1109922
def rm(path):
    
    if path and os.path.exists(path):
        if os.path.isdir(path):
            shutil.rmtree(path)
        else:
            os.remove(path)
104573
def CleanUp(self, path):
    """"""
    try:
      if os.path.exists(path):
        os.remove(path)
    except (OSError, IOError) as e:
      logging.info("Failed to remove temporary file %s. Err: %s", path, e)
156643
def remove_temporary_source(self):
        # type: () -> None
        """"""
        if self.source_dir and os.path.exists(
                os.path.join(self.source_dir, PIP_DELETE_MARKER_FILENAME)):
            logger.debug('Removing source in %s', self.source_dir)
            rmtree(self.source_dir)
        self.source_dir = None
        self._temp_build_dir.cleanup()
        self.build_env.cleanup()
122523
def in_source_dir(*paths)
      paths.reduce(source) do |base, path|
        Bunto.sanitized_path(base, path)
      end
    end
1331481
def remove_directory(directory, show_warnings=True):
    """"""
    errors = []

    def onerror(function, path, excinfo):
        if show_warnings:
            print 'Cannot delete %s: %s' % (os.path.relpath(directory), excinfo[1])
        errors.append((function, path, excinfo))

    if os.path.exists(directory):
        if not os.path.isdir(directory):
            raise NotADirectoryError(directory)
        shutil.rmtree(directory, onerror=onerror)

    return errors
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)
609297
def clean(self):
        
        if not util.is_blank(self.catalog.catname) and os.path.exists(self.catalog.catname):
            os.remove(self.catalog.catname)
1184211
def dest_fpath(self, source_fpath: str) -> str:
        """"""
        relative_fpath = os.path.join(*source_fpath.split(os.sep)[1:])
        relative_dirpath = os.path.dirname(relative_fpath)

        source_fname = relative_fpath.split(os.sep)[-1]
        base_fname = source_fname.split('.')[0]
        dest_fname = f'{base_fname}.json'

        return os.path.join(self.dest_dir, relative_dirpath, dest_fname)
81503
def remove(ctx, client, sources):
    """"""
    from renku.api._git import _expand_directories

    def fmt_path(path):
        """Format path as relative to the client path."""
        return str(Path(path).absolute().relative_to(client.path))

    files = {
        fmt_path(source): fmt_path(file_or_dir)
        for file_or_dir in sources
        for source in _expand_directories((file_or_dir, ))
    }

    # 1. Update dataset metadata files.
    with progressbar(
        client.datasets.values(),
        item_show_func=lambda item: str(item.short_id) if item else '',
        label='Updating dataset metadata',
        width=0,
    ) as bar:
        for dataset in bar:
            remove = []
            for key, file_ in dataset.files.items():
                filepath = fmt_path(file_.full_path)
                if filepath in files:
                    remove.append(key)

            if remove:
                for key in remove:
                    dataset.unlink_file(key)

                dataset.to_yaml()

    # 2. Manage .gitattributes for external storage.
    tracked = tuple(
        path for path, attr in client.find_attr(*files).items()
        if attr.get('filter') == 'lfs'
    )
    client.untrack_paths_from_storage(*tracked)
    existing = client.find_attr(*tracked)
    if existing:
        click.echo(WARNING + 'There are custom .gitattributes.\n')
        if click.confirm(
            'Do you want to edit ".gitattributes" now?', default=False
        ):
            click.edit(filename=str(client.path / '.gitattributes'))

    # Finally remove the files.
    final_sources = list(set(files.values()))
    if final_sources:
        run(['git', 'rm', '-rf'] + final_sources, check=True)
1103411
def remove_directory(self, directory_name, *args, **kwargs):
		
		client = self.dav_client()
		remote_path = self.join_path(self.session_path(), directory_name)

		if client.is_dir(remote_path) is False:
			raise ValueError('Unable to remove non-directory entry')
		client.clean(remote_path)
182005
def cli(ctx):
    """"""
    dir_path = os.path.join(os.path.expanduser('~'), '.keep')
    if os.path.exists(dir_path):
        if click.confirm('[CRITICAL] Remove everything inside ~/.keep ?', abort=True):
            shutil.rmtree(dir_path)
    utils.first_time_use(ctx)
366451
def __remove_path(self, path):
        
        curpath = os.path.abspath(os.curdir)
        if not os.path.exists(path):
            logger.warn("Attempted to remove a non-existent path %s" % path)
            return
        try:
            if os.path.islink(path):
                os.unlink(path)
            elif os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.unlink(path)

            # in the case we just deleted ourselves out of a valid directory,
            # we move to a valid directory.
            if curpath == path:
                os.chdir(tempfile.gettempdir())

        except OSError:
            logger.error("Unable to remove object at path %s" % path)
            raise DirectoryException("Unable to remove object at path %s" % path)
615666
def remove_blank_dirs(self):
        """"""
        if self.is_blank():
            try:
                os.rmdir(self.path)
            except OSError as e:
                print(e)
        else:
            remove_empty_dir(self.path)