def checkReplaceSubstring(self, arguments):
    allowedFields = {}
    allowedFields['replace'] = (str, True)
    allowedFields['with']    = (str, True)

    # Loop over all the arguments.
    for category in arguments.keys():
      for argumentAttributes in arguments[category]:

        # Check if the argument has instructions on replacing substrings.
        if 'replace substring' in argumentAttributes:

          # Get the long form argument.
          argument = argumentAttributes['long form argument']
          replace  = argumentAttributes['replace substring']

          # Loop over the list and check that each entry is a dictionary with the correct attributes.
          for data in replace:
            if not methods.checkIsDictionary(data, self.allowTermination):
              if self.allowTermination: self.errors.invalidReplaceSubstring(self.name, category, argument)
              else: return False

            # Check the contained values.
            observedFields = []
            toReplace      = None
            replaceWith    = None
            for key in data:
              value = data[key]
              if key not in allowedFields:
                if self.allowTermination: self.errors.invalidReplaceSubstring(self.name, category, argument)
                else: return False
  
              # Store the value.
              if key == 'replace': toReplace = value
              elif key == 'with': replaceWith = value

              # Record the field as having been observed.
              observedFields.append(key)

            # Store the values.
            self.arguments[argument].isReplaceSubstring    = True
            self.arguments[argument].replaceSubstring.append((str(toReplace), str(replaceWith)))

            # Check that all required fields have been set.
            for field in allowedFields.keys():
              if allowedFields[field][1] and observedFields not in field:
                if self.allowTermination: self.errors.invalidReplaceSubstring(self.name, category, argument)
                else: return False

    # Return success.
    return True

  # Check that instructions on replacing a value with a command are valid.
dataset/ETHPy150Open gkno/gkno_launcher/src/gkno/toolConfiguration.py/toolConfiguration.checkReplaceSubstring/swapped operands of `not in`