Return a new path with the file name changed.
546747
def with_name(self, name):
        """"""
        if not self.name:
            raise ValueError("%r has an empty name" % (self,))
        drv, root, parts = self._flavour.parse_parts((name,))
        if (not name or name[-1] in [self._flavour.sep, self._flavour.altsep]
                or drv or root or len(parts) != 1):
            raise ValueError("Invalid name %r" % (name))
        return self._from_parsed_parts(self._drv, self._root,
                                       self._parts[:-1] + [name])
432319
def copy(self, new_path, replace=False):
        """"""
        if replace or not get_file(new_path).exists():
            self.key.copy(self.key.bucket, new_path)
            return True
        return False
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)
986230
def normalizeFilename(filename):
    
    result = os.path.expanduser(filename)
    result = os.path.abspath(result)
    return result
32840
def new_filename(original_filename, new_locale):
    """"""
    orig_file = Path(original_filename)
    new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name
    return new_file.abspath()
323282
def __filename(self, id):
        """"""
        suffix = self.fnsuffix()
        filename = "%s-%s.%s" % (self.fnprefix, id, suffix)
        return os.path.join(self.location, filename)
641469
def brf(path, f, t):
    """"""
    from .tools.file import batch_rename_file
    batch_rename_file(path, f, t)
848501
def move(self, path, raise_if_exists=False):
        
        self.rename(path, raise_if_exists=raise_if_exists)
1062603
def renamed_tree(self, source, dest):
        """"""
        dirname = osp.abspath(to_text_string(source))
        tofile = to_text_string(dest)
        for fname in self.get_filenames():
            if osp.abspath(fname).startswith(dirname):
                new_filename = fname.replace(dirname, tofile)
                self.renamed(source=fname, dest=new_filename)
689050
def in_path(self, new_path, old_path=None):
        """"""
        self.path = new_path
        try:
            yield
        finally:
            self.path = old_path
249356
public static void rename(FileSystem fs, String oldName, String newName)
    throws IOException {
    Path oldDir = new Path(oldName);
    Path newDir = new Path(newName);
    if (!fs.rename(oldDir, newDir)) {
      throw new IOException("Could not rename " + oldDir + " to " + newDir);
    }
  }
1059860
def get_file_url(path, config):
    
    file_url_regex = re.compile(config['file_url_regex'])
    new_path = re.sub(file_url_regex, config['file_url_base'], path)
    return new_path
1179862
def changed_path(self):
        ""
        result = None  # default
        for path in self.paths_to_modification_times:
            lastmod = self.paths_to_modification_times[path]
            mod = os.path.getmtime(path)
            if mod > lastmod:
                result = "Watch file has been modified: " + repr(path)
            self.paths_to_modification_times[path] = mod
        for folder in self.folder_paths:
            for filename in os.listdir(folder):
                subpath = os.path.join(folder, filename)
                if os.path.isfile(subpath) and subpath not in self.paths_to_modification_times:
                    result = "New file in watched folder: " + repr(subpath)
                    self.add(subpath)
        if self.check_python_modules:
            # refresh the modules
            self.add_all_modules()
        if self.check_javascript:
            self.watch_javascript()
        return result
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
959632
def _gen_full_path(self, filename, file_system=None):
        """"""
        if file_system is None:
            return '{}/{}'.format(self.dest_file_system, filename)
        else:
            if ":" not in file_system:
                raise ValueError("Invalid file_system specified: {}".format(file_system))
            return '{}/{}'.format(file_system, filename)
21950
def path(self, **kwargs):
        
        new_path = path(self.getPath(), **kwargs)
        return File(new_path)
464609
def dir_path(dir):
    """"""
    old_dir = os.getcwd()
    os.chdir(dir)
    yield
    os.chdir(old_dir)