def raise_exception(context, problem, document, location): str_document = dump(document, Dumper=RoundTripDumper) context_line = location.start_line(document) - 1 problem_line = location.end_line(document) - 1 context_index = len('\n'.join(str_document.split('\n')[:context_line])) problem_index = len('\n'.join(str_document.split('\n')[:problem_line])) raise YAMLValidationError( context, StringMark("<unicode string>", context_index, context_line, 0, str_document, context_index + 1), problem, StringMark("<unicode string>", problem_index, problem_line, 0, str_document, problem_index + 1))
def problem_mark(self): problem_line = self._chunk.end_line() - 1 str_document = dump(self._chunk.whole_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)
def context_mark(self): context_line = self._chunk.start_line() - 1 str_document = dump(self._chunk.whole_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)
def get_mark(self): # type: () -> Any if self.stream is None: return StringMark(self.name, self.index, self.line, self.column, self.buffer, self.pointer) else: return FileMark(self.name, self.index, self.line, self.column)
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(u"<unicode string>", context_index, context_line, 0, str_document, context_index + 1) string_mark_b = StringMark(u"<unicode string>", problem_index, problem_line, 0, str_document, problem_index + 1) raise YAMLValidationError( context, string_mark_a, problem, string_mark_b, )