class_docstr: FSEvents based event emitter. Handles conversion of native events.
code: def queue_events(self, timeout):
      events = self._fsevents.read_events()
      if events is None:
          return
      i = 0
      while i < len(events):
          event = events[i]
  
          # For some reason the create and remove flags are sometimes also
          # set for rename and modify type events, so let those take
          # precedence.
          if event.is_renamed:
              # Internal moves appears to always be consecutive in the same
              # buffer and have IDs differ by exactly one (while others
              # don't) making it possible to pair up the two events coming
              # from a singe move operation. (None of this is documented!)
              # Otherwise, guess whether file was moved in or out.
              # TODO: handle id wrapping
              if (
                  i + 1 < len(events)
                  and events[i + 1].is_renamed
                  and events[i + 1].event_id == event.event_id + 1
              ):
                  cls = (
                      DirMovedEvent
                      if event.is_directory
                      else FileMovedEvent
                  )
                  self.queue_event(cls(event.path, events[i + 1].path))
                  self.queue_event(
                      DirModifiedEvent(os.path.dirname(event.path))
                  )
                  self.queue_event(
                      DirModifiedEvent(
                          os.path.dirname(events[i + 1].path)
                      )
                  )
                  i += 1
              elif os.path.exists(event.path):
                  cls = (
                      DirCreatedEvent
                      if event.is_directory
                      else FileCreatedEvent
                  )
                  self.queue_event(cls(event.path))
                  self.queue_event(
                      DirModifiedEvent(os.path.dirname(event.path))
                  )
              else:
                  cls = (
                      DirDeletedEvent
                      if event.is_directory
                      else FileDeletedEvent
                  )
                  self.queue_event(cls(event.path))
                  self.queue_event(
                      DirModifiedEvent(os.path.dirname(event.path))
                  )
              # TODO: generate events for tree
  
          elif (
              event.is_modified
              or event.is_inode_meta_mod
              or event.is_xattr_mod
          ):
              cls = (
                  DirModifiedEvent
                  if event.is_directory
                  else FileModifiedEvent
              )
              self.queue_event(cls(event.path))
  
          elif event.is_created:
              cls = (
                  DirCreatedEvent
                  if event.is_directory
                  else FileCreatedEvent
              )
              self.queue_event(cls(event.path))
              self.queue_event(
                  DirModifiedEvent(os.path.dirname(event.path))
              )
  
          elif event.is_removed:
              cls = (
                  DirDeletedEvent
                  if event.is_directory
                  else FileDeletedEvent
              )
              self.queue_event(cls(event.path))
              self.queue_event(
                  DirModifiedEvent(os.path.dirname(event.path))
              )
          i += 1
  
imports: import os
  import logging
  import unicodedata
  from threading import Thread
  from wandb_watchdog.utils.compat import queue
  from wandb_watchdog.events import FileDeletedEvent, FileModifiedEvent, FileCreatedEvent, FileMovedEvent, DirDeletedEvent, DirModifiedEvent, DirCreatedEvent, DirMovedEvent
  from wandb_watchdog.observers.api import BaseObserver, EventEmitter, DEFAULT_EMITTER_TIMEOUT, DEFAULT_OBSERVER_TIMEOUT
  import AppKit
  from FSEvents import FSEventStreamCreate, CFRunLoopGetCurrent, FSEventStreamScheduleWithRunLoop, FSEventStreamStart, CFRunLoopRun, CFRunLoopStop, FSEventStreamStop, FSEventStreamInvalidate, FSEventStreamRelease
  from FSEvents import kCFAllocatorDefault, kCFRunLoopDefaultMode, kFSEventStreamEventIdSinceNow, kFSEventStreamCreateFlagNoDefer, kFSEventStreamCreateFlagFileEvents, kFSEventStreamEventFlagItemCreated, kFSEventStreamEventFlagItemRemoved, kFSEventStreamEventFlagItemInodeMetaMod, kFSEventStreamEventFlagItemRenamed, kFSEventStreamEventFlagItemModified, kFSEventStreamEventFlagItemFinderInfoMod, kFSEventStreamEventFlagItemChangeOwner, kFSEventStreamEventFlagItemXattrMod, kFSEventStreamEventFlagItemIsDir, kFSEventStreamEventFlagItemIsSymlink
label_desc: Use image node_id 3 for calling the FSEventsEmitter obj's underlying member method code with example usage: obj.queue_events(timeout) without return types