Skip to content

Commit

Permalink
print graph CBDs in the output
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Dec 2, 2024
1 parent bdf578c commit a39dd28
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion buildingmotif/dataclasses/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ class OrShape(GraphDiff):

def reason(self) -> str:
"""Human-readable explanation of this GraphDiff."""
return f"{self.focus} needs to match one of the following shapes: {', '.join(self.shapes)}"
context = ""
for shape in self.shapes:
# get the CBD of the shape
shape_graph = self.graph.cbd(shape)
# serialize the shape graph to a string
shape_str = shape_graph.serialize(format="turtle")
context += f"Shape: {shape}\n{shape_str}\n"

return f"{self.focus} needs to match one of the following shapes: {', '.join(self.shapes)}\n{context}"

@classmethod
def from_validation_report(cls, report: Graph) -> List["OrShape"]:
Expand Down

0 comments on commit a39dd28

Please sign in to comment.