Skip to content

Commit 54d419d

Browse files
committed
T9169: expose diff_show for refactor check
1 parent b4c60cd commit 54d419d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

python/vyos/configtree.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,32 @@ def diff_compare(left, right, path=None, commands=False, libpath=LIBPATH):
579579
return res
580580

581581

582+
def diff_show(rt, left, right, path=None, libpath=LIBPATH):
583+
if not (isinstance(left, ConfigTree) and isinstance(right, ConfigTree)):
584+
raise TypeError('Arguments must be instances of ConfigTree')
585+
path = path or []
586+
587+
check_path(path)
588+
path_str = ' '.join(map(str, path)).encode()
589+
590+
__lib = cdll.LoadLibrary(libpath)
591+
__diff_show = __lib.diff_show
592+
__diff_show.argtypes = [c_void_p, c_void_p, c_void_p, c_char_p]
593+
__diff_show.restype = c_char_p
594+
__get_error = __lib.get_error
595+
__get_error.argtypes = []
596+
__get_error.restype = c_char_p
597+
598+
res = __diff_show(rt.get_tree(), left.get_tree(), right.get_tree(), path_str)
599+
res = res.decode()
600+
if res == '#1@':
601+
msg = __get_error().decode()
602+
raise ConfigTreeError(msg)
603+
604+
res = unescape_backslash(res)
605+
return res
606+
607+
582608
def union(left, right, libpath=LIBPATH):
583609
if left is None:
584610
left = ConfigTree(config_string='\n')

0 commit comments

Comments
 (0)