Skip to content

Commit 09c4b42

Browse files
committed
clarification
1 parent 6a03544 commit 09c4b42

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

libyang/data.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ def dict_to_dnode(
12731273

12741274
created = []
12751275

1276-
def _create_leaf(_parent_cdata, module, name, value, in_rpc_output=False):
1276+
def _create_leaf(refcnt_parent, _parent_cdata, module, name, value, in_rpc_output=False):
12771277
if value is not None:
12781278
if isinstance(value, bool):
12791279
value = str(value).lower()
@@ -1293,20 +1293,20 @@ def _create_leaf(_parent_cdata, module, name, value, in_rpc_output=False):
12931293

12941294
if ret != lib.LY_SUCCESS:
12951295
if _parent_cdata:
1296-
parent_path = repr(DNode.new(module.context, _parent_cdata, parent).path())
1296+
parent_path = repr(DNode.new(module.context, _parent_cdata, refcnt_parent).path())
12971297
else:
12981298
parent_path = "module %r" % module.name()
12991299
raise module.context.error(
13001300
"failed to create leaf %r as a child of %s", name, parent_path
13011301
)
13021302
created.append(n[0])
13031303

1304-
def _create_container(_parent_cdata, module, name, in_rpc_output=False):
1304+
def _create_container(refcnt_parent, _parent_cdata, module, name, in_rpc_output=False):
13051305
n = ffi.new("struct lyd_node **")
13061306
ret = lib.lyd_new_inner(_parent_cdata, module.cdata, str2c(name), in_rpc_output, n)
13071307
if ret != lib.LY_SUCCESS:
13081308
if _parent_cdata:
1309-
parent_path = repr(DNode.new(module.context, _parent_cdata, parent).path())
1309+
parent_path = repr(DNode.new(module.context, _parent_cdata, refcnt_parent).path())
13101310
else:
13111311
parent_path = "module %r" % module.name()
13121312
raise module.context.error(
@@ -1317,7 +1317,7 @@ def _create_container(_parent_cdata, module, name, in_rpc_output=False):
13171317
created.append(n[0])
13181318
return n[0]
13191319

1320-
def _create_list(_parent_cdata, module, name, key_values, in_rpc_output=False):
1320+
def _create_list(refcnt_parent, _parent_cdata, module, name, key_values, in_rpc_output=False):
13211321
n = ffi.new("struct lyd_node **")
13221322
flags = newval_flags(rpc_output=in_rpc_output, store_only=store_only)
13231323
ret = lib.lyd_new_list(
@@ -1330,7 +1330,7 @@ def _create_list(_parent_cdata, module, name, key_values, in_rpc_output=False):
13301330
)
13311331
if ret != lib.LY_SUCCESS:
13321332
if _parent_cdata:
1333-
parent_path = repr(DNode.new(module.context, _parent_cdata, parent).path())
1333+
parent_path = repr(DNode.new(module.context, _parent_cdata, refcnt_parent).path())
13341334
else:
13351335
parent_path = "module %r" % module.name()
13361336
raise module.context.error(
@@ -1386,7 +1386,7 @@ def _dic_keys(_dic, _schema):
13861386
return keys
13871387
return _dic.keys()
13881388

1389-
def _to_dnode(_dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
1389+
def _to_dnode(refcnt_parent, _dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
13901390
for key in _dic_keys(_dic, _schema):
13911391
if ":" in key:
13921392
prefix, name = key.split(":")
@@ -1409,7 +1409,7 @@ def _to_dnode(_dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
14091409
value = _dic[key]
14101410

14111411
if isinstance(s, SLeaf):
1412-
_create_leaf(_parent_cdata, module, name, value, in_rpc_output)
1412+
_create_leaf(refcnt_parent, _parent_cdata, module, name, value, in_rpc_output)
14131413

14141414
elif isinstance(s, SLeafList):
14151415
if not isinstance(value, (list, tuple)):
@@ -1418,14 +1418,14 @@ def _to_dnode(_dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
14181418
% (s.schema_path(), value)
14191419
)
14201420
for v in value:
1421-
_create_leaf(_parent_cdata, module, name, v, in_rpc_output)
1421+
_create_leaf(refcnt_parent, _parent_cdata, module, name, v, in_rpc_output)
14221422

14231423
elif isinstance(s, SRpc):
1424-
n = _create_container(_parent_cdata, module, name, in_rpc_output)
1424+
n = _create_container(refcnt_parent, _parent_cdata, module, name, in_rpc_output)
14251425
_to_dnode(value, s, n, rpcreply)
14261426

14271427
elif isinstance(s, SContainer):
1428-
n = _create_container(_parent_cdata, module, name, in_rpc_output)
1428+
n = _create_container(refcnt_parent, _parent_cdata, module, name, in_rpc_output)
14291429
_to_dnode(value, s, n, in_rpc_output)
14301430

14311431
elif isinstance(s, SList):
@@ -1450,11 +1450,11 @@ def _to_dnode(_dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
14501450
except KeyError as e:
14511451
raise ValueError("Missing key %s in the list" % (k)) from e
14521452

1453-
n = _create_list(_parent_cdata, module, name, key_values, in_rpc_output)
1453+
n = _create_list(refcnt_parent, _parent_cdata, module, name, key_values, in_rpc_output)
14541454
_to_dnode(val, s, n, in_rpc_output)
14551455

14561456
elif isinstance(s, SNotif):
1457-
n = _create_container(_parent_cdata, module, name, in_rpc_output)
1457+
n = _create_container(refcnt_parent, _parent_cdata, module, name, in_rpc_output)
14581458
_to_dnode(value, s, n, in_rpc_output)
14591459

14601460
result = None
@@ -1468,6 +1468,7 @@ def _to_dnode(_dic, _schema, _parent_cdata=ffi.NULL, in_rpc_output=False):
14681468
_schema_parent = module
14691469

14701470
_to_dnode(
1471+
parent,
14711472
dic,
14721473
_schema_parent,
14731474
_parent_cdata,

0 commit comments

Comments
 (0)