summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2026-08-14 15:47:41 +0100
committerGitHub <noreply@github.com>2026-08-14 15:47:41 +0100
commitf7e2b424894859029025e4a8a02882f230f98132 (patch)
treec2eb5eedc438aad4d68c13354d8f6443b2ee9d66 /python
parentbbe4079eb322f18fdac14ceedee7ad0ed94d6897 (diff)
parent54d419d6ed43f5c3365799ad96dbfc91fd37ac37 (diff)
downloadvyos-1x-f7e2b424894859029025e4a8a02882f230f98132.tar.gz
vyos-1x-f7e2b424894859029025e4a8a02882f230f98132.zip
Merge pull request #5395 from jestabro/diff-functor
T9169: update for vyos1x-config refactor
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configtree.py42
1 files changed, 34 insertions, 8 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index a70aac095..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')
@@ -630,14 +656,14 @@ def mask_inclusive(left, right, libpath=LIBPATH):
try:
__lib = cdll.LoadLibrary(libpath)
- __mask_tree = __lib.mask_tree
- __mask_tree.argtypes = [c_void_p, c_void_p, c_bool]
- __mask_tree.restype = c_void_p
+ __mask_inclusive = __lib.mask_inclusive
+ __mask_inclusive.argtypes = [c_void_p, c_void_p]
+ __mask_inclusive.restype = c_void_p
__get_error = __lib.get_error
__get_error.argtypes = []
__get_error.restype = c_char_p
- res = __mask_tree(left.get_tree(), right.get_tree(), False)
+ res = __mask_inclusive(left.get_tree(), right.get_tree())
except Exception as e:
raise ConfigTreeError(e)
if not res:
@@ -656,14 +682,14 @@ def mask_exclusive(left, right, libpath=LIBPATH):
try:
__lib = cdll.LoadLibrary(libpath)
- __mask_tree = __lib.mask_tree
- __mask_tree.argtypes = [c_void_p, c_void_p, c_bool]
- __mask_tree.restype = c_void_p
+ __mask_exclusive = __lib.mask_exclusive
+ __mask_exclusive.argtypes = [c_void_p, c_void_p]
+ __mask_exclusive.restype = c_void_p
__get_error = __lib.get_error
__get_error.argtypes = []
__get_error.restype = c_char_p
- res = __mask_tree(left.get_tree(), right.get_tree(), True)
+ res = __mask_exclusive(left.get_tree(), right.get_tree())
except Exception as e:
raise ConfigTreeError(e)
if not res: