old_contents: from ruamel.yaml import MarkedYAMLError
  from ruamel.yaml.dumper import RoundTripDumper
  from ruamel.yaml import dump
  try:
      from ruamel.yaml.error import Mark as StringMark
  except ImportError:
      from ruamel.yaml.error import StringMark
  
  
  class StrictYAMLError(MarkedYAMLError):
      pass
  
  
  class YAMLValidationError(StrictYAMLError):
      pass
  
  
  class DisallowedToken(StrictYAMLError):
      MESSAGE = "Disallowed token"
  
  
  class TagTokenDisallowed(DisallowedToken):
      MESSAGE = "Tag tokens not allowed"
  
  
  class FlowMappingDisallowed(DisallowedToken):
      MESSAGE = "Flow mapping tokens not allowed"
  
  
  class AnchorTokenDisallowed(DisallowedToken):
      MESSAGE = "Anchor tokens not allowed"
  
  
  class DuplicateKeysDisallowed(DisallowedToken):
      MESSAGE = "Duplicate keys not allowed"
  
  
  def raise_exception(context, problem, chunk):
      context_line = chunk.start_line() - 1
      problem_line = chunk.end_line() - 1
      str_document = dump(chunk.document, Dumper=RoundTripDumper)
      context_index = len(u'\n'.join(str_document.split(u'\n')[:context_line]))
      problem_index = len(u'\n'.join(str_document.split(u'\n')[:problem_line]))
      string_mark_a = StringMark(
          chunk.label, context_index, context_line, 0, str_document, context_index + 1
      )
      string_mark_b = StringMark(
          chunk.label, problem_index, problem_line, 0, str_document, problem_index + 1
      )
      raise YAMLValidationError(
          context,
          string_mark_a,
          problem,
          string_mark_b,
      )
  
  
  def raise_type_error(yaml_object, to_type, alternatives):
      raise TypeError((
          "Cannot cast {0} to {1}.\n"
          "Use {2} instead."
      ).format(repr(yaml_object), to_type, alternatives))
  
new_contents: from ruamel.yaml import MarkedYAMLError
  from ruamel.yaml.dumper import RoundTripDumper
  from ruamel.yaml import dump
  try:
      from ruamel.yaml.error import Mark as StringMark
  except ImportError:
      from ruamel.yaml.error import StringMark
  
  
  class StrictYAMLError(MarkedYAMLError):
      pass
  
  
  class YAMLValidationError(StrictYAMLError):
      def __init__(self, context, problem, chunk):
          self.context = context
          self.problem = problem
          self._chunk = chunk
          self.note = None
  
      @property
      def context_mark(self):
          context_line = self._chunk.start_line() - 1
          str_document = dump(self._chunk.document, Dumper=RoundTripDumper)
          context_index = len(u'\n'.join(str_document.split(u'\n')[:context_line]))
          return StringMark(
              self._chunk.label, context_index, context_line, 0, str_document, context_index + 1
          )
  
      @property
      def problem_mark(self):
          problem_line = self._chunk.end_line() - 1
          str_document = dump(self._chunk.document, Dumper=RoundTripDumper)
          problem_index = len(u'\n'.join(str_document.split(u'\n')[:problem_line]))
          return StringMark(
              self._chunk.label, problem_index, problem_line, 0, str_document, problem_index + 1
          )
  
  
  class DisallowedToken(StrictYAMLError):
      MESSAGE = "Disallowed token"
  
  
  class TagTokenDisallowed(DisallowedToken):
      MESSAGE = "Tag tokens not allowed"
  
  
  class FlowMappingDisallowed(DisallowedToken):
      MESSAGE = "Flow mapping tokens not allowed"
  
  
  class AnchorTokenDisallowed(DisallowedToken):
      MESSAGE = "Anchor tokens not allowed"
  
  
  class DuplicateKeysDisallowed(DisallowedToken):
      MESSAGE = "Duplicate keys not allowed"
  
  
  def raise_exception(context, problem, chunk):
      """
      context_line = chunk.start_line() - 1
      problem_line = chunk.end_line() - 1
      str_document = dump(chunk.document, Dumper=RoundTripDumper)
      context_index = len(u'\n'.join(str_document.split(u'\n')[:context_line]))
      problem_index = len(u'\n'.join(str_document.split(u'\n')[:problem_line]))
      string_mark_a = StringMark(
          chunk.label, context_index, context_line, 0, str_document, context_index + 1
      )
      string_mark_b = StringMark(
          chunk.label, problem_index, problem_line, 0, str_document, problem_index + 1
      )
      raise YAMLValidationError(
          context,
          string_mark_a,
          problem,
          string_mark_b,
      )
      """
      raise YAMLValidationError(
          context,
          problem,
          chunk,
      )
  
  
  def raise_type_error(yaml_object, to_type, alternatives):
      raise TypeError((
          "Cannot cast {0} to {1}.\n"
          "Use {2} instead."
      ).format(repr(yaml_object), to_type, alternatives))
  
subject: REFACTOR : Run strictyaml faster when dealing with OrValidators that consistently fail on the first validator.