| Total Complexity | 4 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Coverage | 52.94% |
| Changes | 0 | ||
| 1 | # Copyright 2022, Red Hat, Inc. |
||
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
||
| 3 | 1 | import json |
|
| 4 | 1 | import logging |
|
| 5 | 1 | from io import BytesIO |
|
| 6 | |||
| 7 | 1 | from .report_generator import ReportGenerator |
|
| 8 | |||
| 9 | |||
| 10 | 1 | class JSONReportGenerator(ReportGenerator): |
|
| 11 | 1 | def __init__(self, parser): |
|
| 12 | super().__init__(parser) |
||
| 13 | self.get_report_dict = self.report.as_dict_for_default_json |
||
| 14 | |||
| 15 | 1 | def generate_report(self, debug_setting): |
|
| 16 | logging.warning("JSON Format is experimental output!") |
||
| 17 | indent = "\t" if debug_setting.no_minify else None |
||
| 18 | json_data = json.dumps(self.get_report_dict(), indent=indent) |
||
| 19 | return BytesIO(json_data.encode()) |
||
| 20 | |||
| 21 | |||
| 22 | 1 | class JSONEverythingReportGenerator(JSONReportGenerator): |
|
| 23 | 1 | def __init__(self, parser): |
|
| 24 | super().__init__(parser) |
||
| 25 | self.get_report_dict = self.report.as_dict |
||
| 26 |