コード例 #1
0
 def as_yaml(self):
     """
     Render the YAML node and subnodes as string.
     """
     dumped = dump(self.as_marked_up(),
                   Dumper=StrictYAMLDumper,
                   allow_unicode=True)
     return dumped if sys.version_info[0] == 3 else dumped.decode("utf8")
コード例 #2
0
ファイル: yamlpointer.py プロジェクト: crdoconnor/strictyaml
    def start_line(self, document):
        slicedpart = self._slice_segment(
            self._indices, document, include_selected=False
        )

        if slicedpart is None or slicedpart == {} or slicedpart == []:
            return 1
        else:
            return (
                len(dump(slicedpart, Dumper=RoundTripDumper).rstrip().split("\n")) + 1
            )
コード例 #3
0
ファイル: exceptions.py プロジェクト: crdoconnor/strictyaml
 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,
     )
コード例 #4
0
ファイル: exceptions.py プロジェクト: crdoconnor/strictyaml
 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,
     )
コード例 #5
0
ファイル: yamlpointer.py プロジェクト: crdoconnor/strictyaml
 def lines_after(self, document, how_many):
     return "\n".join(
         dump(document, Dumper=RoundTripDumper).split("\n")[
             self.end_line(document) : self.end_line(document) + how_many
         ]
     )
コード例 #6
0
ファイル: yamlpointer.py プロジェクト: crdoconnor/strictyaml
 def lines_before(self, document, how_many):
     return "\n".join(
         dump(document, Dumper=RoundTripDumper).split("\n")[
             self.start_line(document) - 1 - how_many : self.start_line(document) - 1
         ]
     )
コード例 #7
0
ファイル: yamlpointer.py プロジェクト: crdoconnor/strictyaml
 def lines(self, document):
     return "\n".join(
         dump(document, Dumper=RoundTripDumper).split("\n")[
             self.start_line(document) - 1 : self.end_line(document)
         ]
     )
コード例 #8
0
ファイル: yamlpointer.py プロジェクト: crdoconnor/strictyaml
 def end_line(self, document):
     slicedpart = self._slice_segment(self._indices, document, include_selected=True)
     return len(dump(slicedpart, Dumper=RoundTripDumper).rstrip().split("\n"))