i_vis/core/file_utils.py
def prefix_fname(fname: str, pre: str, tag: Optional[str] = None) -> str:
    """Prefix filename and add optional tag.

    Args:
        fname: Filename to process.
        pre: Prefix to add to filename.
        tag: (Optional). Tag to add to filename. Default = None.

    Returns:
        Prefixed and optionally tagged filename.

    Examples:
        >>> prefix_fname("file.txt", "backup")
        "backup-file.txt"

        >>> prefix_fname("/dir/file.txt", "backup", "old")
        "/dir/backup-old-file.txt"
    """
    dname = os.path.dirname(fname)
    if dname:
        dname = dname + "/"
    fname = os.path.basename(fname).lstrip("_")
    if tag:
        pre = f"{pre}-{tag}"
    pre = f"{pre}-"
    return f"{dname}{pre}{fname}"
Prefix filename and add optional tag.

    Args:
        fname: Filename to process.
        pre: Prefix to add to filename.
        tag: (Optional). Tag to add to filename. Default = None.

    Returns:
        Prefixed and optionally tagged filename.

    Examples:
        >>> prefix_fname("file.txt", "backup")
        "backup-file.txt"

        >>> prefix_fname("/dir/file.txt", "backup", "old")
        "/dir/backup-old-file.txt"
    
Prefix filename and add optional tag.
Prefix filename and add optional tag .
def prefix_fname(fname: str, pre: str, tag: Optional[str] = None) -> str:
    dname = os.path.dirname(fname)
    if dname:
        dname = dname + "/"
    fname = os.path.basename(fname).lstrip("_")
    if tag:
        pre = f"{pre}-{tag}"
    pre = f"{pre}-"
    return f"{dname}{pre}{fname}"
def prefix_fname ( fname : str , pre : str , tag : Optional [ str ] = None ) -> str : dname = os . path . dirname ( fname ) if dname : dname = dname + "/" fname = os . path . basename ( fname ) . lstrip ( "_" ) if tag : pre = f"{pre}-{tag}" pre = f"{pre}-" return f"{dname}{pre}{fname}"
Prefix filename and add optional tag.
Prefix filename and add optional tag .
"""Prefix filename and add optional tag.

    Args:
        fname: Filename to process.
        pre: Prefix to add to filename.
        tag: (Optional). Tag to add to filename. Default = None.

    Returns:
        Prefixed and optionally tagged filename.

    Examples:
        >>> prefix_fname("file.txt", "backup")
        "backup-file.txt"

        >>> prefix_fname("/dir/file.txt", "backup", "old")
        "/dir/backup-old-file.txt"
    """
Prefixed and optionally tagged filename.
Prefixed and optionally tagged filename .
fname
str
Filename to process.
Filename to process .
pre
str
Prefix to add to filename.
Prefix to add to filename .
tag
Optional[str]
(Optional). Tag to add to filename. Default = None.
( Optional ) . Tag to add to filename . Default = None .
examples
>>> prefix_fname("file.txt", "backup")
"backup-file.txt"

>>> prefix_fname("/dir/file.txt", "backup", "old")
"/dir/backup-old-file.txt"
>>> prefix_fname ( " file . txt " " backup " ) " backup - file . txt " >>> prefix_fname ( " / dir / file . txt " " backup " " old " ) " / dir / backup - old - file . txt "