<commit_before>module ManageIQ::Providers
  class Amazon::NetworkManager::Refresher < ManageIQ::Providers::BaseManager::Refresher
    include ::EmsRefresh::Refreshers::EmsRefresherMixin

    def parse_legacy_inventory(ems)
      if refresher_options.try(:[], :inventory_object_refresh)
        ManageIQ::Providers::Amazon::NetworkManager::RefreshParserInventoryObject.ems_inv_to_hashes(ems, refresher_options)
      else
        ManageIQ::Providers::Amazon::NetworkManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options)
      end
    end

    def post_process_refresh_classes
      []
    end
  end
end<commit_msg>Change AWS Network Refresher to the new format<commit_after>module ManageIQ::Providers
  class Amazon::NetworkManager::Refresher < ManageIQ::Providers::BaseManager::Refresher
    include ::EmsRefresh::Refreshers::EmsRefresherMixin

    def collect_inventory_for_targets(ems, targets)
      targets_with_data = targets.collect do |target|
        target_name = target.try(:name) || target.try(:event_type)

        _log.info "Filtering inventory for #{target.class} [#{target_name}] id: [#{target.id}]..."

        inventory = if refresher_options.try(:[], :inventory_object_refresh)
                      ManageIQ::Providers::Amazon::Inventory::Factory.inventory(ems, target)
                    else
                      nil
                    end

        _log.info "Filtering inventory...Complete"
        [target, inventory]
      end

      targets_with_data
    end

    def parse_targeted_inventory(ems, _target, inventory)
      log_header = format_ems_for_logging(ems)
      _log.debug "#{log_header} Parsing inventory..."
      hashes, = Benchmark.realtime_block(:parse_inventory) do
        if refresher_options.try(:[], :inventory_object_refresh)
          ManageIQ::Providers::Amazon::NetworkManager::RefreshParserInventoryObject.new(inventory).populate_inventory_collections
        else
          ManageIQ::Providers::Amazon::NetworkManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options)
        end
      end
      _log.debug "#{log_header} Parsing inventory...Complete"

      hashes
    end

    def post_process_refresh_classes
      []
    end
  end
end
{'fraction_non_alphanumeric': 0.09732910819375283, 'fraction_numerical': 0.0, 'mean_word_length': 3.6041666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2652902', 'n_tokens_mistral': 666, 'n_tokens_neox': 640, 'n_words': 105}