code: def _ensure_single_source(path, filesystem=None):
      """
      Treat path as either a recursively traversable directory or a single file.
  
      Parameters
      ----------
      path : path-like
      filesystem : FileSystem or str, optional
          If an URI is passed, then its path component will act as a prefix for
          the file paths.
  
      Returns
      -------
      (FileSystem, list of str or fs.Selector)
          File system object and either a single item list pointing to a file or
          an fs.Selector object pointing to a directory.
  
      Raises
      ------
      TypeError
          If the passed filesystem has wrong type.
      FileNotFoundError
          If the referenced file or directory doesn't exist.
      """
      from pyarrow.fs import (
          FileType,
          FileSelector,
          _resolve_filesystem_and_path,
      )
  
      # at this point we already checked that `path` is a path-like
      filesystem, path = _resolve_filesystem_and_path(path, filesystem)
  
      # ensure that the path is normalized before passing to dataset discovery
      path = filesystem.normalize_path(path)
  
      # retrieve the file descriptor
      file_info = filesystem.get_file_info(path)
  
      # depending on the path type either return with a recursive
      # directory selector or as a list containing a single file
      if file_info.type == FileType.Directory:
          paths_or_selector = FileSelector(path, recursive=True)
      elif file_info.type == FileType.File:
          paths_or_selector = [path]
      else:
          raise FileNotFoundError(path)
  
      return filesystem, paths_or_selector
  
file_path: arrow/python/pyarrow/dataset.py
imports: import pyarrow
  from pyarrow.util import _is_iterable, _stringify_path, _is_path_like
  from pyarrow.compute import Expression, scalar, field
label_desc: Use image node_id 6 for calling a global function with example usage: _ensure_single_source(path, filesystem) and returns: filesystem,  paths_or_selector