Module providing the public function of the magni.utils subpackage.
Split a path into folder path, file name, and file extension.
The returned folder path ends with a folder separation character while the returned file extension starts with an extension separation character. The function is independent of the operating system and thus of the use of folder separation character and extension separation character.
Parameters: path (str) – The path of the file either absolute or relative to the current working directory. Returns:
- path (str) – The path of the containing folder of the input path.
- name (str) – The name of the object which the input path points to.
- ext (str) – The extension of the object which the input path points to (if any).
Concatenate a dummy path and split it using the present function:
>>> import os >>> from magni.utils._util import split_path >>> path = 'folder' + os.sep + 'file' + os.path.extsep + 'extension' >>> parts = split_path(path) >>> print(tuple((parts[-7:-1], parts, parts[1:]))) ('folder', 'file', 'extension')