Skip to content

Commit e1a0175

Browse files
rwestphalrjarry
authored andcommitted
data: expose lyd_merge()
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
1 parent aa24e3a commit e1a0175

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cffi/cdefs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ typedef enum {
402402
#define LYD_OPT_TRUSTED ...
403403
#define LYD_OPT_DATA_NO_YANGLIB ...
404404
#define LYD_OPT_RPC ...
405+
#define LYD_OPT_EXPLICIT ...
406+
#define LYD_OPT_DESTRUCT ...
407+
#define LYD_OPT_NOSIBLINGS ...
405408

406409
typedef union lyd_value_u {
407410
int8_t bln;
@@ -442,6 +445,7 @@ double lyd_dec64_to_double(const struct lyd_node *);
442445
void lyd_free(struct lyd_node *);
443446
void lyd_free_withsiblings(struct lyd_node *);
444447
int lyd_validate(struct lyd_node **, int, void *);
448+
int lyd_merge(struct lyd_node *, const struct lyd_node *, int);
445449

446450
/* from libc, needed to free allocated strings */
447451
void free(void *);

libyang/data.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def path_flags(update=False, rpc_output=False, no_parent_ret=False):
5858

5959
#------------------------------------------------------------------------------
6060
def parser_flags(data=False, config=False, get=False, strict=False,
61-
trusted=False, no_yanglib=False, rpc=False):
61+
trusted=False, no_yanglib=False, rpc=False, destruct=False,
62+
no_siblings=False, explicit=False):
6263
flags = 0
6364
if data:
6465
flags |= lib.LYD_OPT_DATA
@@ -74,6 +75,12 @@ def parser_flags(data=False, config=False, get=False, strict=False,
7475
flags |= lib.LYD_OPT_DATA_NO_YANGLIB
7576
if rpc:
7677
flags |= lib.LYD_OPT_RPC
78+
if destruct:
79+
flags |= lib.LYD_OPT_DESTRUCT
80+
if no_siblings:
81+
flags |= lib.LYD_OPT_NOSIBLINGS
82+
if explicit:
83+
flags |= lib.LYD_OPT_EXPLICIT
7784
return flags
7885

7986

@@ -165,6 +172,13 @@ def validate(self, data=False, config=False, get=False, strict=False,
165172
if ret != 0:
166173
self.context.error('validation failed')
167174

175+
def merge(self, source, destruct=False, no_siblings=False, explicit=False):
176+
flags = parser_flags(destruct=destruct, no_siblings=no_siblings,
177+
explicit=explicit)
178+
ret = lib.lyd_merge(self._node, source._node, flags)
179+
if ret != 0:
180+
raise self.context.error('merge failed')
181+
168182
def print_mem(self, fmt,
169183
with_siblings=False,
170184
pretty=False,

0 commit comments

Comments
 (0)