Total Complexity | 3 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Coverage | 50% |
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): # pylint: disable=W0231 |
|
12 | self.report = parser.parse_report() |
||
13 | |||
14 | 1 | def generate_report(self, debug_setting): |
|
15 | logging.warning("JSON Format is experimental output!") |
||
16 | |||
17 | indent = None |
||
18 | if debug_setting.no_minify: |
||
19 | indent = "\t" |
||
20 | json_data = json.dumps(self.report.as_dict(), indent=indent) |
||
21 | return BytesIO(json_data.encode()) |
||
22 |