original_docstring: 
          This function takes all DirEntry from the list and removes all but the most recent one
          by ts_updated timestamp. It returns the most recent DirEntry and removes the others by
          direct datastore operations. If there are multiple entries with most recent timestamp, the
          first encountered is kept and the others non-deterministically removed.
          Note: This operation can be called for DirEntries without common keys, e.g. for all
          entries registering an agent for a device.
          
docstring: This function takes all DirEntry from the list and removes all but the most recent one
  by ts_updated timestamp. It returns the most recent DirEntry and removes the others by
  direct datastore operations. If there are multiple entries with most recent timestamp, the
  first encountered is kept and the others non-deterministically removed.
  Note: This operation can be called for DirEntries without common keys, e.g. for all
  entries registering an agent for a device.
docstring_tokens: This function takes all DirEntry from the list and removes all but the most recent one by ts_updated timestamp . It returns the most recent DirEntry and removes the others by direct datastore operations . If there are multiple entries with most recent timestamp the first encountered is kept and the others non - deterministically removed . Note : This operation can be called for DirEntries without common keys e . g . for all entries registering an agent for a device .
code: def _cleanup_outdated_entries(self, dir_entries, common="key"):
          """
          This function takes all DirEntry from the list and removes all but the most recent one
          by ts_updated timestamp. It returns the most recent DirEntry and removes the others by
          direct datastore operations. If there are multiple entries with most recent timestamp, the
          first encountered is kept and the others non-deterministically removed.
          Note: This operation can be called for DirEntries without common keys, e.g. for all
          entries registering an agent for a device.
          """
          if not dir_entries:
              return
          newest_entry = dir_entries[0]
          try:
              for de in dir_entries:
                  if int(de.ts_updated) > int(newest_entry.ts_updated):
                      newest_entry = de
  
              remove_list = [de for de in dir_entries if de is not newest_entry]
  
              log.info("Attempting to cleanup these directory entries: %s" % remove_list)
              for de in remove_list:
                  try:
                      self.dir_store.delete(de)
                  except Exception as ex:
                      log.warn("Removal of outdated %s directory entry failed: %s" % (common, de))
              log.info("Cleanup of %s old %s directory entries succeeded" % (len(remove_list), common))
  
          except Exception as ex:
              log.warn("Cleanup of multiple directory entries for %s failed: %s" % (
                  common, str(ex)))
  
          return newest_entry
code_tokens: def _cleanup_outdated_entries ( self , dir_entries , common = "key" ) : if not dir_entries : return newest_entry = dir_entries [ 0 ] try : for de in dir_entries : if int ( de . ts_updated ) > int ( newest_entry . ts_updated ) : newest_entry = de remove_list = [ de for de in dir_entries if de is not newest_entry ] log . info ( "Attempting to cleanup these directory entries: %s" % remove_list ) for de in remove_list : try : self . dir_store . delete ( de ) except Exception as ex : log . warn ( "Removal of outdated %s directory entry failed: %s" % ( common , de ) ) log . info ( "Cleanup of %s old %s directory entries succeeded" % ( len ( remove_list ) , common ) ) except Exception as ex : log . warn ( "Cleanup of multiple directory entries for %s failed: %s" % ( common , str ( ex ) ) ) return newest_entry
short_docstring: This function takes all DirEntry from the list and removes all but the most recent one
  by ts_updated timestamp.
short_docstring_tokens: This function takes all DirEntry from the list and removes all but the most recent one by ts_updated timestamp .
comment: """
          This function takes all DirEntry from the list and removes all but the most recent one
          by ts_updated timestamp. It returns the most recent DirEntry and removes the others by
          direct datastore operations. If there are multiple entries with most recent timestamp, the
          first encountered is kept and the others non-deterministically removed.
          Note: This operation can be called for DirEntries without common keys, e.g. for all
          entries registering an agent for a device.
          """