mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +00:00
bimtester: report, simplify generation code
This commit is contained in:
@@ -8,9 +8,9 @@ from .features.steps.utils import switch_locale
|
|||||||
|
|
||||||
|
|
||||||
def generate_report(
|
def generate_report(
|
||||||
adir=".",
|
report_dir=".",
|
||||||
use_report_folder=True,
|
use_report_folder=True,
|
||||||
report_file_name="",
|
report_file_name="report.json",
|
||||||
html_template_file_path=""
|
html_template_file_path=""
|
||||||
):
|
):
|
||||||
|
|
||||||
@@ -32,23 +32,18 @@ def generate_report(
|
|||||||
if html_template_file_path:
|
if html_template_file_path:
|
||||||
report_template_path = html_template_file_path
|
report_template_path = html_template_file_path
|
||||||
|
|
||||||
# get report file
|
# get report file and report dir
|
||||||
report_dir = adir
|
|
||||||
if use_report_folder:
|
if use_report_folder:
|
||||||
report_dir = os.path.join(adir, "report")
|
report_dir = os.path.join(report_dir, "report")
|
||||||
if not os.path.exists(report_dir):
|
report_file = os.path.join(report_dir, report_file_name)
|
||||||
return print("No report directory was found.")
|
# print(report_file)
|
||||||
|
if not os.path.isdir(report_dir):
|
||||||
if report_file_name:
|
return print("Report directory does not exist.")
|
||||||
report_path = os.path.join(report_dir, report_file_name)
|
if not os.path.isfile(report_file):
|
||||||
else:
|
return print("Report file does not exist.")
|
||||||
report_path = os.path.join(report_dir, "report.json")
|
|
||||||
# print(report_path)
|
|
||||||
if not os.path.exists(report_path):
|
|
||||||
return print("No report data was found.")
|
|
||||||
|
|
||||||
# read json report and create html report for each feature
|
# read json report and create html report for each feature
|
||||||
report = json.loads(open(report_path).read())
|
report = json.loads(open(report_file).read())
|
||||||
for feature in report:
|
for feature in report:
|
||||||
file_name = os.path.basename(feature["location"]).split(":")[0]
|
file_name = os.path.basename(feature["location"]).split(":")[0]
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user