Skip to content

Commit 2a67053

Browse files
committed
context: update of paring operations
This patch introduces usage of parsing flags within lyd_parse_op API call and exposed functions Signed-off-by: Stefan Gula <steweg@gmail.com>
1 parent bbb1178 commit 2a67053

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cffi/cdefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ LY_ERR ly_out_new_file(FILE *, struct ly_out **);
349349
LY_ERR ly_out_new_fd(int, struct ly_out **);
350350

351351
LY_ERR lyd_parse_data(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, uint32_t, uint32_t, struct lyd_node **);
352-
LY_ERR lyd_parse_op(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, enum lyd_type, struct lyd_node **, struct lyd_node **);
352+
LY_ERR lyd_parse_op(const struct ly_ctx *, struct lyd_node *, struct ly_in *, LYD_FORMAT, enum lyd_type, uint32_t, struct lyd_node **, struct lyd_node **);
353353

354354
typedef enum {
355355
LYS_OUT_UNKNOWN,

libyang/context.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ def parse_op(
536536
in_data: Union[IO, str],
537537
dtype: DataType,
538538
parent: DNode = None,
539+
opaq: bool = False,
540+
strict: bool = False,
539541
) -> DNode:
540542
fmt = data_format(fmt)
541543
data = ffi.new("struct ly_in **")
@@ -545,13 +547,14 @@ def parse_op(
545547
if ret != lib.LY_SUCCESS:
546548
raise self.error("failed to read input data")
547549

550+
flags = parser_flags(opaq=opaq, strict=strict)
548551
tree = ffi.new("struct lyd_node **", ffi.NULL)
549552
op = ffi.new("struct lyd_node **", ffi.NULL)
550553
par = ffi.new("struct lyd_node **", ffi.NULL)
551554
if parent is not None:
552555
par[0] = parent.cdata
553556

554-
ret = lib.lyd_parse_op(self.cdata, par[0], data[0], fmt, dtype, tree, op)
557+
ret = lib.lyd_parse_op(self.cdata, par[0], data[0], fmt, dtype, flags, tree, op)
555558
lib.ly_in_free(data[0], 0)
556559
if ret != lib.LY_SUCCESS:
557560
raise self.error("failed to parse input data")
@@ -564,9 +567,17 @@ def parse_op_mem(
564567
data: str,
565568
dtype: DataType = DataType.DATA_YANG,
566569
parent: DNode = None,
570+
opaq: bool = False,
571+
strict: bool = False,
567572
):
568573
return self.parse_op(
569-
fmt, in_type=IOType.MEMORY, in_data=data, dtype=dtype, parent=parent
574+
fmt,
575+
in_type=IOType.MEMORY,
576+
in_data=data,
577+
dtype=dtype,
578+
parent=parent,
579+
opaq=opaq,
580+
strict=strict,
570581
)
571582

572583
def parse_data(

0 commit comments

Comments
 (0)