Render a FS object as text tree views.

Color is supported on UNIX terminals.

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

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 or None) – Unicode encoding, or None to auto-detect.
  • max_levels (int or None) – Maximum number of levels to display, or None for no maximum.
  • with_color (bool or None) – Enable terminal color output, or None to auto-detect terminal.
  • dirs_first (bool) – Show directories first.
  • exclude (list or None) – Option list of directory patterns to exclude from the tree render.
  • filter (list or None) – Optional list of files patterns to match in the tree render.

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

Return type:

(int, int)