get_project_structure¶
- pyhelpers.ops.get_project_structure(start_path, ignore_dirs=None, out_file=None, encoding='utf-8', print_in_console=True)[source]¶
Prints and/or writes the directory and file structure of a given project folder starting from
start_path.The output shows a tree-like hierarchy with branch symbols for better readability.
- Parameters:
start_path (str | pathlib.Path) – Path to the root directory whose structure to visualize; can be absolute or relative to the current working directory.
ignore_dirs (None | typying.Iterable) – Optional set of directory names to ignore during traversal; defaults to
{'__pycache__'}.out_file (str | None) – Optional file path to write the structure output. If
None(default), no file will be written. If specified, the structure will be saved to the specified file path.encoding (str) – The encoding to use when writing to the output file; defaults to
'utf-8'.print_in_console (bool) – Whether to print the structure to the console; defaults to
True.
Examples:
>>> from pyhelpers.ops import get_project_structure >>> get_project_structure(start_path="pyhelpers") >>> get_project_structure("my_project", print_in_console=False, out_file="structure.txt")