poseinterface.utils.tree#

poseinterface.utils.tree(dir_path, *, level=-1, limit_to_directories=False, exclude_hidden=False, length_limit=1000)[source]#

Return a visual tree structure of a directory as a string.

Parameters:
  • dir_path (Path) – Path to the root directory.

  • level (int) – Maximum depth to display. -1 means no limit. Default is -1.

  • limit_to_directories (bool) – If True, only directories are shown. Default is False.

  • exclude_hidden (bool) – If True, files and directories starting with . are excluded. Default is False.

  • length_limit (int) – Maximum number of lines to include before truncating. Default is 1000.

Returns:

Tree representation of the directory structure, including a summary line with the count of directories and files.

Return type:

str

Notes

Based on https://stackoverflow.com/a/59109706 by Aaron Hall, modified by community (see post ‘Timeline’ for change history). Retrieved 2026-03-27. License: CC BY-SA 4.0.

Examples

>>> from pathlib import Path
>>> from poseinterface.utils import tree
>>> print(tree(Path(".")))