diff --git a/compliance_check_html.py b/compliance_check_html.py
index ffa49506..bcb3e55b 100644
--- a/compliance_check_html.py
+++ b/compliance_check_html.py
@@ -1,49 +1,18 @@
from template_checker import TemplateChecker, CheckResult
from jinja2 import Template
+def load_template(template_path: str) -> Template:
+ """
+ Load an HTML template from the template.html file
-# Define the template for Jinja
-html_template = """
-
-
-
-
-
- DICOM Header Compliance Report
-
-
- Header |
- Expected Value |
- Actual Value |
-
- {% for row in rows %}
-
- {{ row.header }} |
- {{ row.expected_value }} |
- {{ row.actual_value }} |
-
- {% endfor %}
-
-
-
-"""
+ :param template_path: Path to the HTML template file.
+ :returns: A Jinja2 Template object.
+ """
+ with open(template_path, 'r') as file:
+ template_content = file.read()
+ return Template(template_content)
-def generate_html_report(check_result: CheckResult) -> str:
+def generate_html_report(check_result: CheckResult, template_path: str) -> str:
"""
Generate an HTML report of DICOM header comparison, highlighting mismatches.
@@ -69,8 +38,10 @@ def generate_html_report(check_result: CheckResult) -> str:
"class_name": class_name
})
+ # Load the template from the file
+ template = load_template(template_path)
+
# Render the template with the data
- template = Template(html_template)
html = template.render(rows=rows)
return html
diff --git a/template.html b/template.html
new file mode 100644
index 00000000..069b5da5
--- /dev/null
+++ b/template.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+ DICOM Header Compliance Report
+
+
+ Header |
+ Expected Value |
+ Actual Value |
+
+ {% for row in rows %}
+
+ {{ row.header }} |
+ {{ row.expected_value }} |
+ {{ row.actual_value }} |
+
+ {% endfor %}
+
+
+
+