MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _basename

Function _basename

tools/python-3.11.9-amd64/Lib/shutil.py:793–809  ·  view source on GitHub ↗

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/') '' >>>

(path)

Source from the content-addressed store, hash-verified

791rmtree.avoids_symlink_attacks = _use_fd_functions
792
793def _basename(path):
794 """A basename() variant which first strips the trailing slash, if present.
795 Thus we always get the last component of the path, even for directories.
796
797 path: Union[PathLike, str]
798
799 e.g.
800 >>> os.path.basename('/bar/foo')
801 'foo'
802 >>> os.path.basename('/bar/foo/')
803 ''
804 >>> _basename('/bar/foo/')
805 'foo'
806 """
807 path = os.fspath(path)
808 sep = os.path.sep + (os.path.altsep or '')
809 return os.path.basename(path.rstrip(sep))
810
811def move(src, dst, copy_function=copy2):
812 """Recursively move a file or directory to another location. This is

Callers 1

moveFunction · 0.85

Calls 2

basenameMethod · 0.80
rstripMethod · 0.45

Tested by

no test coverage detected