Return a new path with the file suffix changed (or added, if
        none).
969247
def with_suffix(self, suffix):
        
        # XXX if suffix is None, should the current suffix be removed?
        f = self._flavour
        if f.sep in suffix or f.altsep and f.altsep in suffix:
            raise ValueError("Invalid suffix %r" % (suffix))
        if suffix and not suffix.startswith('.') or suffix == '.':
            raise ValueError("Invalid suffix %r" % (suffix))
        name = self.name
        if not name:
            raise ValueError("%r has an empty name" % (self,))
        old_suffix = self.suffix
        if not old_suffix:
            name = name + suffix
        else:
            name = name[:-len(old_suffix)] + suffix
        return self._from_parsed_parts(self._drv, self._root,
                                       self._parts[:-1] + [name])
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
1307775
def cwd(self, new_path):
        ''''''
        old_cwd = self._cwd
        self._cwd = new_path
        return old_cwd
547623
def _path_formatter(self, suffix):
        
        if suffix.lower() == "mirror":
            path_items = [self.bucket, self.s3path]
        else:
            path_items = [self.bucket, self.s3path, suffix]

        path = '/'.join(path_items)
        s3_format = "s3://{}"
        formatted_path = path.replace('//', '/')  # removes configuration errors
        full_path = s3_format.format(formatted_path)
        return full_path
537256
def norm_join(prefix, suffix):
    
    if (prefix is None) and (suffix is None):
        return "."
    if prefix is None:
        return os.path.normpath(suffix)
    if suffix is None:
        return os.path.normpath(prefix)
    return os.path.normpath(os.path.join(prefix, suffix))
1359628
def expandPath (pathname, prefix=None):
    
    if prefix is None:
        prefix = ''

    expanded = pathname

    if pathname[0] == '~':
        expanded = os.path.expanduser(pathname)
    elif pathname[0] != '/':
        expanded = os.path.join(prefix, pathname)

    return os.path.abspath(expanded)
841800
public static boolean pathEndsWith(File file, String suffix) {
		return file.getPath().toLowerCase().endsWith(suffix);
	}
7453
def _replace_file(path, content):
  """"""
  if os.path.exists(path):
    with open(path, 'r') as f:
      if content == f.read():
        print("Not overwriting {} because it is unchanged".format(path), file=sys.stderr)
        return

  with open(path, 'w') as f:
    f.write(content)
437188
def add_suffix(fullname, suffix):
    
    name, ext = os.path.splitext(fullname)
    return name + '_' + suffix + ext
1134690
def expand_path(path):
  
  return os.path.abspath(os.path.expandvars(os.path.expanduser(path)))
206135
def rename_with_prefix(self, prefix="", new_path=None, in_place=True, remove_desc=True):
        """"""
        # Temporary path #
        if new_path is None: prefixed = self.__class__(new_temp_path())
        else:                prefixed = self.__class__(new_path)
        # Generator #
        def prefixed_iterator():
            for i,read in enumerate(self):
                read.id = prefix + read.id
                if remove_desc: read.description = ""
                yield read
        # Do it #
        prefixed.write(prefixed_iterator())
        prefixed.close()
        # Replace it #
        if in_place:
            os.remove(self.path)
            shutil.move(prefixed, self.path)
        return prefixed
62600
def add_to_path(p):
    '''
        
    '''
    old_path = sys.path
    if p not in sys.path:
        sys.path = sys.path[:]
        sys.path.insert(0, p)
    try:
        yield
    finally:
        sys.path = old_path
1041901
def add_suffix(filename, suffix):
        
        path = filename.split("/")
        parts = path[-1].split(".")
        i = max(len(parts) - 2, 0)
        parts[i] = parts[i] + suffix
        path[-1] = ".".join(parts)
        return "/".join(path)
510015
def replace_suffix(to_transform, suffix):
    
    if is_sequence(to_transform):
        transformed = []
        for f in to_transform:
            (base, _) = os.path.splitext(f)
            transformed.append(base + suffix)
        return transformed
    elif is_string(to_transform):
        (base, _) = os.path.splitext(to_transform)
        return base + suffix
    else:
        raise ValueError("replace_suffix takes a single filename as a string or "
                         "a list of filenames to transform.")
297450
def inflect(self, filename):
        
        suffix = ("/" if os.path.isdir(filename) else " ")
        return self._escape(filename) + suffix
98844
def get_file_suffix(self, path, prefix):
        
        try:
            number_of_files = len(glob.glob(os.path.join(path, prefix) + '*'))
        except:
            number_of_files = 0
        return '{0:04}'.format(number_of_files)
1251111
def replace_path(path, name=nil)
      name ||= File.basename path
      self.replace_pattern path, name
    end