3030from . import Template
3131from lotemplate .Statement .CalcSearchStatement import CalcTextStatement
3232import pdb
33+ from jsondiff import diff
3334
3435class CalcTemplate (Template ):
3536 formats = {
@@ -82,14 +83,11 @@ def scan(self, **kwargs) -> dict[str: dict[str, Union[str, list[str]]]]:
8283 should_close = kwargs .get ("should_close" , False )
8384 texts = {}
8485 #(Pdb) self.doc.getSheets().getElementNames()
85- #('maF1', 'Feuille2')
86- #(Pdb) self.doc.getSheets().getByName('maF1')
8786 for sheet in self .doc .getSheets ():
8887 texts = texts | CalcTextStatement .scan (sheet )
8988 tables = CalcTableStatement .scan (self .doc )
90- #range.getElementNames()
9189 #texts = CalcTextStatement.scan_Document_text(self.doc)
92-
90+ #pdb.set_trace()
9391 return texts | tables
9492
9593
@@ -100,17 +98,15 @@ def search_error(self, json_vars: dict[str, dict[str, Union[str, list[str]]]]) -
10098 :param json_vars: the given json variables
10199 :return: None
102100 """
103-
104- if json_vars == self . variables :
101+ notdiff = diff ( json_vars , self . variables )
102+ if not notdiff :
105103 return
106-
107- json_missing = [key for key in set (self .variables ) - set (json_vars )]
108- if json_missing :
109- raise errors .JsonComparaisonError (
104+ else :
105+ raise errors .JsonComparaisonError (
110106 'missing_required_variable' ,
111- f"The variable { json_missing [ 0 ]!r } , present in the template, "
112- f"isn't present in the json. " ,
113- dict (variable = json_missing [ 0 ] )
107+ f"The json are not the same here is the diff "
108+ f"{ notdiff } " ,
109+ dict (variable = notdiff )
114110 )
115111
116112 # when parsing the template, we assume that all vars are of type text. But it can also be of type html.
0 commit comments