docbuild.utils.paths#
Module for Path related utilities.
Functions#
|
Calculate the maximum length of file names. |
Module Contents#
- docbuild.utils.paths.calc_max_len(files: tuple[pathlib.Path | str, Ellipsis], last_parts: int = -2) int #
Calculate the maximum length of file names.
Shortens the filenames to the last parts of the path (last_parts) for display purposes, ensuring the maximum length is even.
- Parameters:
files – A tuple of file paths to calculate lengths for.
last_parts – Number of parts from the end of the path to consider. Needs to be negative to count from the end. By default, it considers the last two parts.
- Returns:
The maximum length of the shortened file names.
>>> files = (Path('/path/to/file1.xml'), Path('/another/path/to/file2.xml')) >>> calc_max_len(files) 30