def _GroupHuntsAndPluginsByVerifiers(self, hunts):
    hunts_by_urns = {}
    for hunt in hunts:
      hunts_by_urns[hunt.urn] = hunt

    results_metadata_urns = [hunt.urn.Add("ResultsMetadata") for hunt in hunts]
    results_metadata_objects = aff4.FACTORY.MultiOpen(
        results_metadata_urns, aff4_type=HuntResultsMetadata.__name__,
        token=self.token)

    results = {}

    for mdata in results_metadata_objects:
      hunt_urn = rdfvalue.RDFURN(mdata.urn.Dirname())
      hunt = hunts_by_urns[hunt_urn]

      for plugin_id, (plugin_descriptor, plugin_state) in mdata.Get(
          mdata.Schema.OUTPUT_PLUGINS, {}).items():

        plugin_obj = plugin_descriptor.GetPluginForState(plugin_state)
        plugin_verifiers_classes = plugin_descriptor.GetPluginVerifiersClasses()

        if not plugin_verifiers_classes:
          results.setdefault(self.NON_VERIFIABLE, []).append(
              (plugin_id, plugin_descriptor, plugin_obj, hunt))
        else:
          for cls in plugin_verifiers_classes:
            results.setdefault(cls, []).append(
                (plugin_id, plugin_descriptor, plugin_obj, hunt))

    return results
Opens hunts results metadata in bulk and groups the by verifier type.
dataset/ETHPy150Open google/grr/grr/lib/hunts/standard.py/VerifyHuntOutputPluginsCronFlow._GroupHuntsAndPluginsByVerifiers