From 36fc0e07da40eae8694f1f661fe6d18f15d1c583 Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Mon, 15 Jan 2024 13:41:55 +0100 Subject: [PATCH] Fix import problem No module named 'json2html' --- utils/profile_tool/stats.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/profile_tool/stats.py b/utils/profile_tool/stats.py index a3ff5a026e6..55ce6493f3e 100644 --- a/utils/profile_tool/stats.py +++ b/utils/profile_tool/stats.py @@ -1,11 +1,18 @@ import os import json -from json2html import json2html from ssg.build_profile import XCCDFBenchmark from ssg.utils import mkdir_p +OFF_JSON_TO_HTML = False + +try: + from json2html import json2html +except ImportError: + OFF_JSON_TO_HTML = True + + def _process_stats_content(profile, bash_fixes_count, content, content_filepath): link = """
{}
""" count = len(profile[content]) @@ -98,6 +105,9 @@ def command_stats(args): print(json.dumps(profiles, indent=4)) elif args.format == "html": + if OFF_JSON_TO_HTML: + print("No module named 'json2html'. Please install module to enable this function.") + return _generate_html_stats(args, profiles) elif args.format == "csv":