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.-1means no limit. Default is-1.limit_to_directories (
bool) – IfTrue, only directories are shown. Default isFalse.exclude_hidden (
bool) – IfTrue, files and directories starting with.are excluded. Default isFalse.length_limit (
int) – Maximum number of lines to include before truncating. Default is1000.
- Returns:
Tree representation of the directory structure, including a summary line with the count of directories and files.
- Return type:
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(".")))