Convert a FileRenameCommand into a new FileCommand.

        :return: None if the rename is being ignored, otherwise a
          new FileCommand based on the whether the old and new paths
          are inside or outside of the interesting locations.
197301
def _convert_rename(self, fc):
        
        old = fc.old_path
        new = fc.new_path
        keep_old = self._path_to_be_kept(old)
        keep_new = self._path_to_be_kept(new)
        if keep_old and keep_new:
            fc.old_path = self._adjust_for_new_root(old)
            fc.new_path = self._adjust_for_new_root(new)
            return fc
        elif keep_old:
            # The file has been renamed to a non-interesting location.
            # Delete it!
            old = self._adjust_for_new_root(old)
            return commands.FileDeleteCommand(old)
        elif keep_new:
            # The file has been renamed into an interesting location
            # We really ought to add it but we don't currently buffer
            # the contents of all previous files and probably never want
            # to. Maybe fast-import-info needs to be extended to
            # remember all renames and a config file can be passed
            # into here ala fast-import?
            self.warning("cannot turn rename of %s into an add of %s yet" %
                (old, new))
        return None
245166
def path_dispatch_rename(rename_like_method):
        

        def _wrapper_method(self, old_path, new_path):
            old_path, _old_path, old_sentinel =  _split_path(old_path);
            new_path, _new_path, new_sentinel =  _split_path(new_path);

            if old_sentinel != new_sentinel:
                raise ValueError('Does not know how to move things across contents manager mountpoints')
            else:
                sentinel = new_sentinel


            man = self.managers.get(sentinel, None)
            if man is not None:
                rename_meth = getattr(man, rename_like_method.__name__)
                sub = rename_meth('/'.join(_old_path), '/'.join(_new_path))
                return sub
            else :
                return rename_meth(self, old_path, new_path)
        return _wrapper_method
846771
def rename!(old_path, target_path)
      old_path    = "root.#{old_path}" unless old_path.include? 'root.'
      target_path = "root.#{target_path}" unless target_path.include? 'root.'

      unless _option = root.get_path(target_path)
        raise OptionNotExist, "option #{target_path} does not exist -  target path must exist for rename."
      end

      _parent, _name = old_path.option_path_split
      _section = root.get_path(_parent)

      renamed_option = RenamedOption.new(_name, _section, _option)

      begin
        _section.add_option(_name, renamed_option)
      rescue OptionExists => e
        raise RenameFailed, "Unable to rename #{old_path} -> #{target_path}"
      end
    end
862656
def rename(name, new_name, root=None):
    '''
    
    '''
    if info(new_name, root=root):
        raise CommandExecutionError('User \'{0}\' already exists'.format(new_name))

    return _chattrib(name, 'name', new_name, '-l', root=root)
847123
def batch_rename_file(path, f, t):
    """"""
    files = os.listdir(path)
    for file in files:
        if f in file:
            new_fn = file.replace(f, t)
            old = os.path.join(path, file)
            new = os.path.join(path, new_fn)
            os.rename(old, new)
952044
def rename(path, new_name, options={})
      raise ArgumentError, "Names cannot have slashes in them" if new_name.include?('/')
      path = path.sub(/\/$/, '')
      destination = path.split('/')
      destination[destination.size - 1] = new_name
      destination = destination.join('/')
      move path, destination, options
    end
700738
@Override
  public int rename(String oldPath, String newPath) {
    final AlluxioURI oldUri = mPathResolverCache.getUnchecked(oldPath);
    final AlluxioURI newUri = mPathResolverCache.getUnchecked(newPath);
    LOG.trace("rename({}, {}) [Alluxio: {}, {}]", oldPath, newPath, oldUri, newUri);

    try {
      mFileSystem.rename(oldUri, newUri);
      synchronized (mOpenFiles) {
        if (mOpenFiles.contains(PATH_INDEX, oldPath)) {
          OpenFileEntry oe = mOpenFiles.getFirstByField(PATH_INDEX, oldPath);
          oe.setPath(newPath);
        }
      }
    } catch (FileDoesNotExistException e) {
      LOG.debug("Failed to rename {} to {}, file {} does not exist", oldPath, newPath, oldPath);
      return -ErrorCodes.ENOENT();
    } catch (FileAlreadyExistsException e) {
      LOG.debug("Failed to rename {} to {}, file {} already exists", oldPath, newPath, newPath);
      return -ErrorCodes.EEXIST();
    } catch (Throwable t) {
      LOG.error("Failed to rename {} to {}", oldPath, newPath, t);
      return AlluxioFuseUtils.getErrorCode(t);
    }

    return 0;
  }
1215581
def rename(src, dst):
    '''
    
    '''
    src = os.path.expanduser(src)
    dst = os.path.expanduser(dst)

    if not os.path.isabs(src):
        raise SaltInvocationError('File path must be absolute.')

    try:
        os.rename(src, dst)
        return True
    except OSError:
        raise CommandExecutionError(
            'Could not rename \'{0}\' to \'{1}\''.format(src, dst)
        )
    return False
1354826
public NfsRenameResponse rename(F toFile) throws IOException {
        NfsRenameResponse response = getNfs().wrapped_sendRename(makeRenameRequest(toFile));
        if (response.stateIsOk()) {
            setPathFields(toFile);
        }
        return response;
    }
905486
def _windows_rename(self, tmp_filename):
        

        os.remove(self.input_file) if os.path.isfile(self.input_file) else None
        os.rename(tmp_filename, self.input_file)
989534
public boolean rename(Path src, Path dst) throws IOException {
    return fs.rename(src, dst);
  }
334813
function renameFile(from, to) {
  return new Promise((resolve, reject) => {
    fs.rename(from, to, (err) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(to);
    });
  });
}
663258
def can_rename(self):
        # type: (LocalSourcePaths) -> bool
        
        return len(self._paths) == 1 and (
            self._paths[0].is_file() or
            blobxfer.models.upload.LocalSourcePath.is_stdin(
                str(self._paths[0]))
        )
940427
public void rename(String oldpath, String newpath)
			throws SftpStatusException, SshException {
		String from = resolveRemotePath(oldpath);
		String to = resolveRemotePath(newpath);

		SftpFileAttributes attrs = null;

		try {
			attrs = sftp.getAttributes(to);

		} catch (SftpStatusException ex) {
			sftp.renameFile(from, to);
			return;
		}

		if (attrs != null && attrs.isDirectory()) {
			sftp.renameFile(from, to);
		} else {
			throw new SftpStatusException(
					SftpStatusException.SSH_FX_FILE_ALREADY_EXISTS, newpath
							+ " already exists on the remote filesystem");
		}

	}
162222
def rename(self, new_dirname=None, new_fname=None, new_ext=None):
        
        if not new_dirname:
            new_dirname = self.dirname
        else:
            new_dirname = os.path.abspath(new_dirname)
        if not new_fname:
            new_fname = self.fname
        if new_ext: # 检查新文件名的扩展名格式是否
            if not new_ext.startswith("."):
                raise ValueError("File extension must in format .ext, "
                                 "for example: .jpg, .mp3")
        else:
            new_ext = self.ext
        new_basename = new_fname + new_ext
        new_abspath = os.path.join(new_dirname, new_basename)

        os.rename(self.abspath, new_abspath)
        # 如果成功重命名, 则更新文件信息
        self.abspath = new_abspath
        self.dirname = new_dirname
        self.basename = new_basename
        self.fname = new_fname
        self.ext = new_ext
350621
def normalize_ext_rename(filepath):
    
    logger.debug('normalize_ext.filepath=' + str(filepath))
    new_file_path = normalize_ext(filepath)
    logger.debug('download_unzip.new_filepaths=' + str(new_file_path))
    # FIXME: fails when name is a url filename
    filepath = rename_file(filepath, new_file_path)
    logger.debug('download_unzip.filepath=' + str(filepath))
    return filepath
129139
def rename(self, src_basename, dest_basename, datadir="outdir"):
        
        directory = {
            "indir": self.indir,
            "outdir": self.outdir,
            "tmpdir": self.tmpdir,
        }[datadir]

        src = directory.path_in(src_basename)
        dest = directory.path_in(dest_basename)

        os.rename(src, dest)