code: def extract_message_to_dict(filename):
      """
      Read in a text file that java messages to be ignored and generate a dictionary structure out of
      it with key and value pairs.  The keys are test names and the values are lists of java message
      strings associated with that test name where we are either going to add to the existing java messages
      to ignore or remove them from g_ok_java_messages.
  
      Parameters
      ----------
  
      filename :  Str
         filename that contains ignored java messages.  The text file shall contain something like this:
          keyName = general
          Message = nfolds: nfolds cannot be larger than the number of rows (406).
          KeyName = pyunit_cv_cars_gbm.py
          Message = Caught exception: Illegal argument(s) for GBM model: GBM_model_python_1452503348770_2586.  \
              Details: ERRR on field: _nfolds: nfolds must be either 0 or >1.
          ...
  
      :return:
      message_dict : dict
          contains java message to be ignored with key as unit test name or "general" and values as list of ignored java
          messages.
      """
      message_dict = {}
  
      if os.path.isfile(filename):
          # open file to read in new exclude messages if it exists
          with open(filename, "r") as wfile:
              key = ""
              val = ""
              startMess = False
  
              while 1:
                  each_line = wfile.readline()
  
                  if not each_line:  # reached EOF
                      if startMess:
                          add_to_dict(val.strip(), key, message_dict)
                      break
  
                  # found a test name or general with values to follow
                  if (
                      "keyname" in each_line.lower()
                  ):  # name of test file or the word "general"
                      temp_strings = each_line.strip().split("=")
  
                      if (
                          len(temp_strings) > 1
                      ):  # make sure the line is formatted sort of correctly
                          if (
                              startMess
                          ):  # this is the start of a new key/value pair
                              add_to_dict(
                                  val.strip(), key, message_dict
                              )
                              val = ""
  
                          key = temp_strings[1].strip()
                          startMess = False
  
                  if (len(each_line) > 1) and startMess:
                      val += each_line
  
                  if "ignoredmessage" in each_line.lower():
                      startMess = True  # start of a Java message.
                      temp_mess = each_line.split("=")
  
                      if len(temp_mess) > 1:
                          val = temp_mess[1]
  
      return message_dict
  
file_path: h2o-3/scripts/addjavamessage2ignore.py
imports: import sys
  import os
  import pickle
  import copy
  import subprocess
label_desc: Use image node_id 5 for calling a global function with example usage: extract_message_to_dict(filename) and returns: message_dict