Symlink an object at path to name in the dir_name folder. remove it if it already exists.
487928
def __symlink_dir(self, dir_name, name, path):
        
        target_dir = os.path.join(self.root_dir, dir_name)
        if not os.path.exists(target_dir):
            os.makedirs(target_dir)
        target_path = os.path.join(self.root_dir, dir_name, name)
        logger.debug("Attempting to symlink %s to %s..." % (path, target_path))
        if os.path.exists(target_path):
            if os.path.islink(target_path):
                os.remove(target_path)
            else:
                logger.warn("%s is not a symlink! please remove it manually." % target_path)
                return
        os.symlink(path, target_path)
1230067
def rmnode(path: str):
    """"""
    if isdir(path):
        rmtree(path)
    elif isfile(path):
        os.remove(path)
92137
def recursive_symlink_dirs(source_d, destination_d):
    '''
    
    '''
    func = os.symlink
    if os.name == 'nt':
        # NOTE: need to verify that default perms only allow admins to create
        # symlinks on Windows
        func = shutil.copy
    if os.path.exists(destination_d):
        os.rmdir(destination_d)
    shutil.copytree(source_d, destination_d, copy_function=func)
302378
def remove_directory(self, directory_name, *args, **kwargs):
		
		previous_path = self.session_path()
		try:
			self.session_path(directory_name)
			os.rmdir(self.full_path())
		finally:
			self.session_path(previous_path)
1083626
def remove_stale_symlinks(path)
      Dir.glob("#{path}/*").each { |f| File.unlink(f) if not File.exist?(f) }
    end
66962
def _clean_directory(self, name):
        """"""
        if not os.path.exists(name):
            return
        self.announce(
            "removing directory '{}' and all its contents".format(name)
        )
        if not self.dry_run:
            rmtree(name, True)
80460
def remove(name, path):
    '''
    
    '''
    cmd = [_get_cmd(), '--remove', name, path]
    out = __salt__['cmd.run_all'](cmd, python_shell=False)
    if out['retcode'] > 0:
        return out['stderr']
    return out['stdout']
1332797
def _ensure_dir_exists(path):
    """"""
    if not op.exists(path):
        os.makedirs(path)
    assert op.exists(path) and op.isdir(path)
333147
def _make_symlink(self, link_name: str, link_target: str):
        ''''''
        path = self._file_writer_session.extra_resource_path('dummy')

        if path:
            dir_path = os.path.dirname(path)
            symlink_path = os.path.join(dir_path, link_name)

            _logger.debug('symlink {} -> {}', symlink_path, link_target)

            os.symlink(link_target, symlink_path)

            _logger.info(
                _('Created symbolic link {symlink_path} to target {symlink_target}.'),
                symlink_path=symlink_path,
                symlink_target=link_target
            )
793416
def delete_dir_rec(path: Path):
    
    if not path.exists() or not path.is_dir():
        return
    for sub in path.iterdir():
        if sub.is_dir():
            delete_dir_rec(sub)
        else:
            sub.unlink()
    path.rmdir()
1041653
def delete_symlink(path)
      if Origen.running_on_windows?
        # Don't use regular rm on windows symlink, will delete into the remote dir!
        system("call cmd /c rmdir #{path.to_s.gsub('/', '\\')}")
        FileUtils.rm_f("#{path}_is_a_symlink")
      else
        FileUtils.rm_f(path)
      end
    end
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
948461
def CreateLibSymlinks(env, symlinks):
    

    Verbose = False
    for link, linktgt in symlinks:
        linktgt = link.get_dir().rel_path(linktgt)
        link = link.get_path()
        if(Verbose):
            print("CreateLibSymlinks: preparing to add symlink %r -> %r" % (link, linktgt))
        # Delete the (previously created) symlink if exists. Let only symlinks
        # to be deleted to prevent accidental deletion of source files...
        if env.fs.islink(link):
            env.fs.unlink(link)
            if(Verbose):
                print("CreateLibSymlinks: removed old symlink %r" % link)
        # If a file or directory exists with the same name as link, an OSError
        # will be thrown, which should be enough, I think.
        env.fs.symlink(linktgt, link)
        if(Verbose):
            print("CreateLibSymlinks: add symlink %r -> %r" % (link, linktgt))
    return 0
951273
def __ensure_directory_in_path(filename: Path) -> None:
    
    directory = Path(filename).parent.resolve()
    if directory not in sys.path:
        logger.debug(f"Adding {directory} to sys.path")
        sys.path.insert(0, str(directory))
792878
function(exists, linkString, callback) {
      if (exists) {
        return callback(null, symlink);
      }
      fs.symlink(linkString, _toFile, function(err) {
        callback(err, symlink);
      });
    }
1061881
function symlinkOrCopySync(dir, target) {
  try {
    symlinkOrCopy.sync(dir, target);
  } catch (e) {
    if (existsSync(target)) {
      rimraf.sync(target);
    }
    symlinkOrCopy.sync(dir, target);
  }
}
1262796
def ensure_dir_exists(path):
    
    dir_path = os.path.dirname(path)
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)