@@ -273,7 +273,13 @@ def create_path(self, tokens):
273273 return JsonPointer .from_parts (tokens ).path
274274
275275 def has_path (self , doc , path ):
276- return JsonPointer (path ).get (doc , default = None ) is not None
276+ return self .get_from_path (doc , path ) is not None
277+
278+ def get_from_path (self , doc , path ):
279+ return JsonPointer (path ).get (doc , default = None )
280+
281+ def is_config_different (self , path , current , target ):
282+ return self .get_from_path (current , path ) != self .get_from_path (target , path )
277283
278284 def get_xpath_tokens (self , xpath ):
279285 """
@@ -558,7 +564,8 @@ def _get_xpath_tokens_from_leaf(self, model, token_index, path_tokens, config):
558564 if uses_leaf_model :
559565 return [token ]
560566
561- raise ValueError ("Token not found" )
567+ raise ValueError (f"Path token not found.\n model: { model } \n token_index: { token_index } \n " + \
568+ f"path_tokens: { path_tokens } \n config: { config } " )
562569
563570 def _extractKey (self , tableKey , keys ):
564571 keyList = keys .split ()
@@ -729,7 +736,8 @@ def _get_path_tokens_from_leaf(self, model, token_index, xpath_tokens, config):
729736 if uses_leaf_model :
730737 return [token ]
731738
732- raise Exception ("no leaf" )
739+ raise ValueError (f"Xpath token not found.\n model: { model } \n token_index: { token_index } \n " + \
740+ f"xpath_tokens: { xpath_tokens } \n config: { config } " )
733741
734742 def _extract_key_dict (self , list_token ):
735743 # Example: VLAN_MEMBER_LIST[name='Vlan1000'][port='Ethernet8']
0 commit comments