# magni.utils._util module¶

Module providing the public function of the magni.utils subpackage.

magni.utils._util.split_path(path)[source]

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. 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).

Examples

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[0][-7:-1], parts[1], parts[2][1:])))
('folder', 'file', 'extension')