MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / parent_directory

Function parent_directory

src/commoncode/fileutils.py:211–220  ·  view source on GitHub ↗

Return the parent directory path of a file or directory `path`. The returned directory has a trailing path separator unless with_trail is False.

(path, force_posix=False, with_trail=True)

Source from the content-addressed store, hash-verified

209
210
211def parent_directory(path, force_posix=False, with_trail=True):
212 """
213 Return the parent directory path of a file or directory `path`.
214 The returned directory has a trailing path separator unless with_trail is False.
215 """
216 left, _right = split_parent_resource(path, force_posix)
217 use_posix = force_posix or is_posixpath(path)
218 sep = "/" if use_posix else "\\"
219 trail = sep if with_trail and left != sep else ""
220 return left + trail
221
222
223def file_base_name(path, force_posix=False):

Callers 7

get_templateFunction · 0.90
build_package_nameFunction · 0.90
parent_pathMethod · 0.90
walkFunction · 0.85

Calls 2

split_parent_resourceFunction · 0.85
is_posixpathFunction · 0.85