fs.tree¶
Render a FS object as text tree views.
Color is supported on UNIX terminals.
- fs.tree.render(fs: FS, path: Text = '/', file: Optional[TextIO] = None, encoding: Optional[Text] = None, max_levels: int = 5, with_color: Optional[bool] = None, dirs_first: bool = True, exclude: Optional[List[Text]] = None, filter: Optional[List[Text]] = None) → Tuple[int, int][source]¶
Render a directory structure in to a pretty tree.
- Parameters
fs (FS) – A filesystem instance.
path (str) – The path of the directory to start rendering from (defaults to root folder, i.e.
'/'
).file (io.IOBase) – An open file-like object to render the tree, or
None
for stdout.encoding (str, optional) – Unicode encoding, or
None
to auto-detect.max_levels (int, optional) – Maximum number of levels to display, or
None
for no maximum.with_color (bool, optional) – Enable terminal color output, or
None
to auto-detect terminal.dirs_first (bool) – Show directories first.
exclude (list, optional) – Option list of directory patterns to exclude from the tree render.
filter (list, optional) – Optional list of files patterns to match in the tree render.
- Returns
A tuple of
(<directory count>, <file count>)
.- Return type
(int, int)