File tree Expand file tree Collapse file tree
src/software_card_policies Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ dependencies = [
1313 " pyshacl[js]>=0.30.0" ,
1414 " rdflib>=7.1.1" ,
1515 " toml>=0.10.2" ,
16- " jinja2>=3.1.6" ,
1716]
1817requires-python = " >=3.10"
1918authors = [
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33# SPDX-FileContributor: David Pape
44
5- from jinja2 import Environment , PackageLoader , select_autoescape
65from rdflib import Graph
76from rdflib .namespace import RDF , SH
87
1211def create_report (validation_graph : Graph , debug = False ) -> str :
1312 shacl_report , * _ = validation_graph .subjects (RDF .type , SH .ValidationReport )
1413 validation_report = ValidationReport .from_graph (shacl_report , validation_graph )
15- environment = Environment (
16- loader = PackageLoader ("software_card_policies" ), autoescape = select_autoescape ()
17- )
18- template = environment .get_template ("report.j2" )
19- return template .render (validation_report = validation_report , debug = debug )
14+
15+ if validation_report .conforms :
16+ return "Validation succeeded!"
17+
18+ text = "Validation failed!\n "
19+ for validation_result in validation_report .results :
20+ text += "\n "
21+ text += f"{ validation_result .severity } :\n "
22+ text += f"Breached policy: { validation_result .source_policy .name } \n "
23+ text += f"{ validation_result .source_policy .description } \n "
24+ if debug :
25+ text += f"Debug: { validation_result .message } \n "
26+
27+ return text
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments