class_docstr: Creates a file explorer component that allows users to browse and select files on the machine hosting the Gradio app.
  Preprocessing: passes the selected file or directory as a {str} path (relative to root) or {list[str}} depending on `file_count`
  Postprocessing: expects function to return a {str} path to a file, or {List[str]} consisting of paths to files.
  Examples-format: a {str} path to a local file that populates the component.
  Demos: zip_to_json, zip_files
class_docstr_tok: ["Creates","a","file","explorer","component","that","allows","users","to","browse","and","select","files","on","the","machine","hosting","the","Gradio","app",".","Preprocessing",":","passes","the","selected","file","or","directory","as","a","{","str","}","path","(","relative","to","root",")","or","{","list","[","str","}","}","depending","on","`","file_count","`","Postprocessing",":","expects","function","to","return","a","{","str","}","path","to","a","file",",","or","{","List","[","str","]","}","consisting","of","paths","to","files",".","Examples-format",":","a","{","str","}","path","to","a","local","file","that","populates","the","component",".","Demos",":","zip_to_json",",","zip_files"]
docstr: Returns:
      tuple of list of files in directory, then list of folders in directory
docstr_tok: ["Returns",":","tuple","of","list","of","files","in","directory",",","then","list","of","folders","in","directory"]
code: def ls(self, _=None) -> list[dict[str, str]] | None:
      """
      Returns:
          tuple of list of files in directory, then list of folders in directory
      """
  
      def expand_braces(text, seen=None):
          if seen is None:
              seen = set()
  
          spans = [m.span() for m in re.finditer("{[^{}]*}", text)][
              ::-1
          ]
          alts = [
              text[start + 1 : stop - 1].split(",")
              for start, stop in spans
          ]
  
          if len(spans) == 0:
              if text not in seen:
                  yield text
              seen.add(text)
  
          else:
              for combo in itertools.product(*alts):
                  replaced = list(text)
                  for (start, stop), replacement in zip(spans, combo):
                      replaced[start:stop] = replacement
  
                  yield from expand_braces("".join(replaced), seen)
  
      def make_tree(files):
          tree = []
          for file in files:
              parts = file.split(os.path.sep)
              make_node(parts, tree)
          return tree
  
      def make_node(parts, tree):
          _tree = tree
          for i in range(len(parts)):
              if _tree is None:
                  continue
              if i == len(parts) - 1:
                  type = "file"
                  _tree.append(
                      {"path": parts[i], "type": type, "children": None}
                  )
                  continue
              type = "folder"
              j = next(
                  (
                      index
                      for (index, v) in enumerate(_tree)
                      if v["path"] == parts[i]
                  ),
                  None,
              )
              if j is not None:
                  _tree = _tree[j]["children"]
              else:
                  _tree.append(
                      {"path": parts[i], "type": type, "children": []}
                  )
                  _tree = _tree[-1]["children"]
  
      files: list[Path] = []
      for result in expand_braces(self.glob):
          files += list(Path(self.root_dir).resolve().glob(result))
  
      files = [f for f in files if f != Path(self.root_dir).resolve()]
  
      ignore_files = []
      if self.ignore_glob:
          for result in expand_braces(self.ignore_glob):
              ignore_files += list(
                  Path(self.root_dir).resolve().glob(result)
              )
          files = list(set(files) - set(ignore_files))
  
      files_with_sep = []
      for f in files:
          file = str(f.relative_to(self.root_dir))
          if f.is_dir():
              file += os.path.sep
          files_with_sep.append(file)
  
      tree = make_tree(files_with_sep)
      return tree
  
imports: from __future__ import annotations
  import itertools
  import os
  import re
  import warnings
  from pathlib import Path
  from typing import Any, Callable, List, Literal
  from gradio_client.documentation import document, set_documentation_group
  from gradio.components.base import Component, server
  from gradio.data_classes import GradioRootModel
label_desc: Use image node_id 6 for calling the FileExplorer obj's underlying member method code with example usage: obj.ls(_) and returns: tree, tree