Example #1
0
 def save(self):
     # load and update, since an execution might have written additional fields to the file since initialization
     run_data = self.__load_data(self._run_file_path)
     run_data.update({
         "result": self.result.name if self.result else None,
         "runtime": self.runtime,
         "message": self.message,
         "md5": self.detector.md5
     })
     write_yaml(run_data, file=self._run_file_path)
 def write_run_file(self, run_data):
     write_yaml(
         run_data,
         join(
             self.findings_path,
             DetectorMode.mine_and_detect.name,
             self.detector.id,
             self.version.project_id,
             self.version.version_id,
             DetectorExecution.RUN_FILE,
         ),
     )
Example #3
0
    def test_writes_object(self):
        class T:
            def __init__(self):
                self.f = 42

        data = write_yaml({"foo": T().__dict__})
        assert_equals("foo:\n  f: 42\n", data)
Example #4
0
 def test_writes_multiline_in_list(self):
     data = write_yaml({"foo": ["a\n"]})
     assert_equals("foo:\n- |\n  a\n", data)
Example #5
0
 def test_writes_multiline_in_dict(self):
     data = write_yaml({"foo": {"bar": "a\n"}})
     assert_equals("foo:\n  bar: |\n    a\n", data)
Example #6
0
 def test_writes_multiline(self):
     data = write_yaml({"foo": "a\nb\n"})
     assert_equals("foo: |\n  a\n  b\n", data)
Example #7
0
 def test_writes_single_line(self):
     data = write_yaml({"foo": "oneliner"})
     assert_equals("foo: oneliner\n", data)
Example #8
0
 def test_writes_dot_graph(self):
     data = write_yaml({"graph": "digraph \"foo\" {\n 1 [label=\"A\"]\n}\n"})
     assert_equals("graph: |\n  digraph \"foo\" {\n   1 [label=\"A\"]\n  }\n", data)
Example #9
0
 def test_writes_multiline_in_dict_in_list(self):
     data = write_yaml({"foo": [{"a": "b\n"}]})
     assert_equals("foo:\n- a: |\n    b\n", data)