class_docstr: A snapshot of stat information of files in a directory.
  
  :param path:
      The directory path for which a snapshot should be taken.
  :type path:
      ``str``
  :param recursive:
      ``True`` if the entire directory tree should be included in the
      snapshot; ``False`` otherwise.
  :type recursive:
      ``bool``
  :param walker_callback:
      .. deprecated:: 0.7.2
  :param stat:
      Use custom stat function that returns a stat structure for path.
      Currently only st_dev, st_ino, st_mode and st_mtime are needed.
      
      A function with the signature ``walker_callback(path, stat_info)``
      which will be called for every entry in the directory tree.
  :param listdir:
      Use custom listdir function. See ``os.listdir`` for details.
class_docstr_tok: ["A","snapshot","of","stat","information","of","files","in","a","directory",".",":","param","path",":","The","directory","path","for","which","a","snapshot","should","be","taken",".",":","type","path",":","``","str","``",":","param","recursive",":","``","True","``","if","the","entire","directory","tree","should","be","included","in","the","snapshot",";","``","False","``","otherwise",".",":","type","recursive",":","``","bool","``",":","param","walker_callback",":","..","deprecated",":",":","0.7.2",":","param","stat",":","Use","custom","stat","function","that","returns","a","stat","structure","for","path",".","Currently","only","st_dev",",","st_ino",",","st_mode","and","st_mtime","are","needed",".","A","function","with","the","signature","``","walker_callback","(","path",",","stat_info",")","``","which","will","be","called","for","every","entry","in","the","directory","tree",".",":","param","listdir",":","Use","custom","listdir","function",".","See","``","os.listdir","``","for","details","."]
code: def __init__(
      self,
      path,
      recursive=True,
      walker_callback=(lambda p, s: None),
      stat=default_stat,
      listdir=os.listdir,
  ):
      self._stat_info = {}
      self._inode_to_path = {}
  
      st = stat(path)
      self._stat_info[path] = st
      self._inode_to_path[(st.st_ino, st.st_dev)] = path
  
      def walk(root):
          try:
              paths = [
                  os.path.join(root, name) for name in listdir(root)
              ]
          except OSError as e:
              # Directory may have been deleted between finding it in the directory
              # list of its parent and trying to delete its contents. If this
              # happens we treat it as empty.
              if e.errno == errno.ENOENT:
                  return
              else:
                  raise
          entries = []
          for p in paths:
              try:
                  entries.append((p, stat(p)))
              except OSError:
                  continue
          for _ in entries:
              yield _
          if recursive:
              for path, st in entries:
                  if S_ISDIR(st.st_mode):
                      for _ in walk(path):
                          yield _
  
      for p, st in walk(path):
          i = (st.st_ino, st.st_dev)
          self._inode_to_path[i] = p
          self._stat_info[p] = st
          walker_callback(p, st)
  
imports: import errno
  import os
  from stat import S_ISDIR
  from wandb_watchdog.utils import stat
label_desc: Use image node_id 1 to create a new DirectorySnapshot object from inherited base classes: object with example: obj = DirectorySnapshot(path, recursive, walker_callback, stat, listdir)