i_vis/core/file_utils.py
def change_suffix(fname: str, new_suffix: str, old_suffix: Optional[str] = None) -> str:
    """Change suffix of filename.

    Changes suffix of a filename. If no old suffix is provided, the part that is replaced is guessed.

    Args:
        fname: Filename to process.
        new_suffix: Replace old suffix with this.
        old_suffix: (Optional) Old suffix of filename - must be part of filename. Default = None.

    Returns:
        Filename with replaced suffix.

    Examples:
        >>> change_suffix("test.txt.gz", "")
        "test.txt"
        >>> change_suffix("test.sorted.txt.gz", ".txt", ".sorted.txt.gz")
        "test.txt"
    """
    if not old_suffix:
        old_suffix = os.path.splitext(fname)[1]
    return str(re.sub(old_suffix + "$", new_suffix, fname))
Change suffix of filename.

    Changes suffix of a filename. If no old suffix is provided, the part that is replaced is guessed.

    Args:
        fname: Filename to process.
        new_suffix: Replace old suffix with this.
        old_suffix: (Optional) Old suffix of filename - must be part of filename. Default = None.

    Returns:
        Filename with replaced suffix.

    Examples:
        >>> change_suffix("test.txt.gz", "")
        "test.txt"
        >>> change_suffix("test.sorted.txt.gz", ".txt", ".sorted.txt.gz")
        "test.txt"
    
Change suffix of filename.
Changes suffix of a filename. If no old suffix is provided, the part that is replaced is guessed.
Change suffix of filename . Changes suffix of a filename . If no old suffix is provided the part that is replaced is guessed .
def change_suffix(fname: str, new_suffix: str, old_suffix: Optional[str] = None) -> str:
    if not old_suffix:
        old_suffix = os.path.splitext(fname)[1]
    return str(re.sub(old_suffix + "$", new_suffix, fname))
def change_suffix ( fname : str , new_suffix : str , old_suffix : Optional [ str ] = None ) -> str : if not old_suffix : old_suffix = os . path . splitext ( fname ) [ 1 ] return str ( re . sub ( old_suffix + "$" , new_suffix , fname ) )
Change suffix of filename.
Change suffix of filename .
"""Change suffix of filename.

    Changes suffix of a filename. If no old suffix is provided, the part that is replaced is guessed.

    Args:
        fname: Filename to process.
        new_suffix: Replace old suffix with this.
        old_suffix: (Optional) Old suffix of filename - must be part of filename. Default = None.

    Returns:
        Filename with replaced suffix.

    Examples:
        >>> change_suffix("test.txt.gz", "")
        "test.txt"
        >>> change_suffix("test.sorted.txt.gz", ".txt", ".sorted.txt.gz")
        "test.txt"
    """
Filename with replaced suffix.
Filename with replaced suffix .
fname
str
Filename to process.
Filename to process .
new_suffix
str
Replace old suffix with this.
Replace old suffix with this .
old_suffix
Optional[str]
(Optional) Old suffix of filename - must be part of filename. Default = None.
( Optional ) Old suffix of filename - must be part of filename . Default = None .
examples
None