original_docstring: 
          Get new and deleted emails for this folder.
          
docstring: Get new and deleted emails for this folder.
docstring_tokens: Get new and deleted emails for this folder .
code: def sync_emails(self, expected_uid_count=None, check_unread_uids=None):
          '''
          Get new and deleted emails for this folder.
          '''
  
          # If we don't exist, try again or we have nothing
          if not self.exists:
              if not self.check_exists():
                  return [], [], []
  
          message_uids = self.get_email_uids(use_cache=False)
  
          # Check the folder UIDVALIDITY (busts the cache if needed)
          uids_valid = self.check_cache_validity()
          uids_changed = False
  
          if uids_valid:
              # Remove existing from new to get anything new
              new_message_uids = message_uids - self.email_uids
              # Remove new from existing to get deleted
              deleted_message_uids = self.email_uids - message_uids
  
              uids_changed = (
                  len(new_message_uids) > 0
                  or len(deleted_message_uids) > 0
              )
          else:
              uids_changed = True
  
              # All old uids invalid, so set all old to deleted
              deleted_message_uids = self.email_uids
  
              batch_size = get_system_setting('batch_size')
              sorted_message_uids = sorted(message_uids, reverse=True)
              new_message_uids = sorted_message_uids[:batch_size]
  
          self.email_uids = message_uids
  
          if uids_changed:
              self.cache_uids()
  
          for uid in deleted_message_uids:
              self.cache.delete_headers(uid)
  
          if expected_uid_count:
              new_message_uids = fix_missing_uids(
                  expected_uid_count, new_message_uids,
              )
  
          self.log('debug', (
              f'Fetched {len(new_message_uids)} new'
              f'/{len(deleted_message_uids)} deleted message IDs'
          ))
  
          new_emails = []
  
          if new_message_uids:
              # Now actually fetch & return those emails
              new_emails = self.get_email_headers(new_message_uids)
              new_emails = list(new_emails.values())
              self.seen_email_uids.update(new_message_uids)
  
          read_uids = []
          if check_unread_uids:
              check_unread_uids = [  # remove any deleted UIDs
                  uid for uid in check_unread_uids
                  if uid in message_uids
              ]
              read_uids = self.check_update_unread_emails(check_unread_uids)
  
          # Return the new emails & any deleted uids
          return new_emails, list(deleted_message_uids), read_uids
code_tokens: def sync_emails ( self , expected_uid_count = None , check_unread_uids = None ) : if not self . exists : if not self . check_exists ( ) : return [ ] , [ ] , [ ] message_uids = self . get_email_uids ( use_cache = False ) uids_valid = self . check_cache_validity ( ) uids_changed = False if uids_valid : new_message_uids = message_uids - self . email_uids deleted_message_uids = self . email_uids - message_uids uids_changed = ( len ( new_message_uids ) > 0 or len ( deleted_message_uids ) > 0 ) else : uids_changed = True deleted_message_uids = self . email_uids batch_size = get_system_setting ( 'batch_size' ) sorted_message_uids = sorted ( message_uids , reverse = True ) new_message_uids = sorted_message_uids [ : batch_size ] self . email_uids = message_uids if uids_changed : self . cache_uids ( ) for uid in deleted_message_uids : self . cache . delete_headers ( uid ) if expected_uid_count : new_message_uids = fix_missing_uids ( expected_uid_count , new_message_uids , ) self . log ( 'debug' , ( f'Fetched {len(new_message_uids)} new' f'/{len(deleted_message_uids)} deleted message IDs' ) ) new_emails = [ ] if new_message_uids : new_emails = self . get_email_headers ( new_message_uids ) new_emails = list ( new_emails . values ( ) ) self . seen_email_uids . update ( new_message_uids ) read_uids = [ ] if check_unread_uids : check_unread_uids = [ uid for uid in check_unread_uids if uid in message_uids ] read_uids = self . check_update_unread_emails ( check_unread_uids ) return new_emails , list ( deleted_message_uids ) , read_uids
short_docstring: Get new and deleted emails for this folder.
short_docstring_tokens: Get new and deleted emails for this folder .
comment: '''
          Get new and deleted emails for this folder.
          '''$SEP$# If we don't exist, try again or we have nothing$SEP$# Check the folder UIDVALIDITY (busts the cache if needed)$SEP$# Remove existing from new to get anything new$SEP$# Remove new from existing to get deleted$SEP$# All old uids invalid, so set all old to deleted$SEP$# Now actually fetch & return those emails$SEP$# remove any deleted UIDs$SEP$# Return the new emails & any deleted uids