From 54d419d6ed43f5c3365799ad96dbfc91fd37ac37 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 12 Aug 2026 08:41:22 -0500 Subject: T9169: expose diff_show for refactor check --- python/vyos/configtree.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'python') diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index 743600a56..6791b1c29 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -579,6 +579,32 @@ def diff_compare(left, right, path=None, commands=False, libpath=LIBPATH): return res +def diff_show(rt, left, right, path=None, libpath=LIBPATH): + if not (isinstance(left, ConfigTree) and isinstance(right, ConfigTree)): + raise TypeError('Arguments must be instances of ConfigTree') + path = path or [] + + check_path(path) + path_str = ' '.join(map(str, path)).encode() + + __lib = cdll.LoadLibrary(libpath) + __diff_show = __lib.diff_show + __diff_show.argtypes = [c_void_p, c_void_p, c_void_p, c_char_p] + __diff_show.restype = c_char_p + __get_error = __lib.get_error + __get_error.argtypes = [] + __get_error.restype = c_char_p + + res = __diff_show(rt.get_tree(), left.get_tree(), right.get_tree(), path_str) + res = res.decode() + if res == '#1@': + msg = __get_error().decode() + raise ConfigTreeError(msg) + + res = unescape_backslash(res) + return res + + def union(left, right, libpath=LIBPATH): if left is None: left = ConfigTree(config_string='\n') -- cgit v1.2.3