Render a FS object as text tree views.

Color is supported on UNIX terminals.

fs.tree.render(fs, path='/', file=None, encoding=None, max_levels=5, with_color=None, dirs_first=True, exclude=None, filter=None)[source]

Render a directory structure in to a pretty tree.

  • 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.

A tuple of (<directory count>, <file count>).

Return type:

(int, int)