code: def _ReadPresetsFromFileObject(self, file_object):
      
      yaml_generator = yaml.safe_load_all(file_object)
  
      last_preset_definition = None
      for yaml_definition in yaml_generator:
        try:
          preset_definition = self._ReadParserPresetValues(yaml_definition)
        except errors.MalformedPresetError as exception:
          error_location = 'At start'
          if last_preset_definition:
            error_location = 'After: {0:s}'.format(last_preset_definition.name)
  
          raise errors.MalformedPresetError(
              '{0:s} {1!s}'.format(error_location, exception))
  
        yield preset_definition
        last_preset_definition = preset_definition
docs: Reads parser and parser plugin presets from a file-like object.
  
      Args:
        file_object (file): file-like object containing the parser and parser
            plugin presets definitions.
  
      Yields:
        ParserPreset: a parser preset.
  
      Raises:
        MalformedPresetError: if one or more plugin preset definitions are
            malformed.