(path)
return os.path.basename(path.rstrip(sep))
A basename() variant which first strips the trailing slash, if present.
    Thus we always get the last component of the path, even for directories.

    path: Union[PathLike, str]

    e.g.
    >>> os.path.basename('/bar/foo')
    'foo'
    >>> os.path.basename('/bar/foo/')
    ''
    >>> _basename('/bar/foo/')
    'foo'
A basename() variant which first strips the trailing slash, if present.
    Thus we always get the last component of the path, even for directories.
A basename () variant which first strips the trailing slash if present . Thus we always get the last component of the path even for directories .
def _basename(path):
    """A basename() variant which first strips the trailing slash, if present.
    Thus we always get the last component of the path, even for directories.

    path: Union[PathLike, str]

    e.g.
    >>> os.path.basename('/bar/foo')
    'foo'
    >>> os.path.basename('/bar/foo/')
    ''
    >>> _basename('/bar/foo/')
    'foo'
    """
    path = os.fspath(path)
    sep = os.path.sep + (os.path.altsep or '')
    return os.path.basename(path.rstrip(sep))
def _basename ( path ) : path = os . fspath ( path ) sep = os . path . sep + ( os . path . altsep or '' ) return os . path . basename ( path . rstrip ( sep ) )