Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions cffi/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ struct lyd_node {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
Expand All @@ -273,7 +273,6 @@ LY_ERR lys_set_implemented(struct lys_module *, const char **);

#define LYD_NEW_VAL_OUTPUT ...
#define LYD_NEW_VAL_STORE_ONLY ...
#define LYD_NEW_VAL_BIN ...
#define LYD_NEW_VAL_CANON ...
#define LYD_NEW_META_CLEAR_DFLT ...
#define LYD_NEW_PATH_UPDATE ...
Expand Down Expand Up @@ -876,9 +875,8 @@ struct lysc_ext {
#define LYS_GETNEXT_WITHCASE ...
#define LYS_GETNEXT_INTONPCONT ...
#define LYS_GETNEXT_OUTPUT ...
#define LYS_GETNEXT_WITHSCHEMAMOUNT ...

const struct lysc_node* lys_find_child(const struct lysc_node *, const struct lys_module *, const char *, size_t, uint16_t, uint32_t);
const struct lysc_node* lys_find_child(const struct ly_ctx *, const struct lysc_node *, const struct lys_module *, const char *, uint32_t, const char *, uint32_t, uint32_t);
const struct lysc_node* lysc_node_child(const struct lysc_node *);
const struct lysc_node_action* lysc_node_actions(const struct lysc_node *);
const struct lysc_node_notif* lysc_node_notifs(const struct lysc_node *);
Expand All @@ -902,7 +900,7 @@ struct lyd_node_inner {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
Expand All @@ -924,7 +922,7 @@ struct lyd_node_term {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
Expand Down Expand Up @@ -984,9 +982,6 @@ struct lysc_must {
struct lysc_ext_instance *exts;
};

struct pcre2_real_code;
typedef struct pcre2_real_code pcre2_code;

struct lysc_pattern {
const char *expr;
const char *dsc;
Expand Down Expand Up @@ -1161,39 +1156,25 @@ struct lyd_meta {
struct lyd_value value;
};

typedef enum {
LYD_ANYDATA_DATATREE,
LYD_ANYDATA_STRING,
LYD_ANYDATA_XML,
LYD_ANYDATA_JSON
} LYD_ANYDATA_VALUETYPE;

union lyd_any_value {
struct lyd_node *tree;
const char *str;
const char *xml;
const char *json;
};

struct lyd_node_any {
union {
struct lyd_node node;
struct {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
};
union lyd_any_value value;
LYD_ANYDATA_VALUETYPE value_type;
struct lyd_node *child;
...;
};

LY_ERR lyd_any_value_str(const struct lyd_node *, char **);
LY_ERR lyd_any_value_str(const struct lyd_node *, LYD_FORMAT, char **);

#define LYD_MERGE_DEFAULTS ...
#define LYD_MERGE_DESTRUCT ...
Expand All @@ -1212,8 +1193,8 @@ LY_ERR lyd_diff_apply_all(struct lyd_node **, const struct lyd_node *);
#define LYD_DUP_WITH_FLAGS ...
#define LYD_DUP_WITH_PARENTS ...

LY_ERR lyd_dup_siblings(const struct lyd_node *, struct lyd_node_inner *, uint32_t, struct lyd_node **);
LY_ERR lyd_dup_single(const struct lyd_node *, struct lyd_node_inner *, uint32_t, struct lyd_node **);
LY_ERR lyd_dup_siblings(const struct lyd_node *, struct lyd_node *, uint32_t, struct lyd_node **);
LY_ERR lyd_dup_single(const struct lyd_node *, struct lyd_node *, uint32_t, struct lyd_node **);
void lyd_free_meta_single(struct lyd_meta *);

struct lysp_tpdf {
Expand Down Expand Up @@ -1291,7 +1272,7 @@ struct lyd_node_opaq {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
Expand Down
4 changes: 2 additions & 2 deletions cffi/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <libyang/libyang.h>
#include <libyang/version.h>

#if LY_VERSION_MAJOR * 10000 + LY_VERSION_MINOR * 100 + LY_VERSION_MICRO < 40202
#error "This version of libyang bindings only works with libyang soversion 4.2.2+"
#if LY_VERSION_MAJOR * 10000 + LY_VERSION_MINOR * 100 + LY_VERSION_MICRO < 50000
#error "This version of libyang bindings only works with libyang soversion 5.0.0+"
#endif
6 changes: 2 additions & 4 deletions libyang/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def newval_flags(
flags |= lib.LYD_NEW_VAL_OUTPUT
if store_only:
flags |= lib.LYD_NEW_VAL_STORE_ONLY
if bin_value:
flags |= lib.LYD_NEW_VAL_BIN
if canon_value:
flags |= lib.LYD_NEW_VAL_CANON
if meta_clear_default:
Expand Down Expand Up @@ -1174,7 +1172,7 @@ class DNotif(DContainer):
class DAnyxml(DNode):
def value(self, fmt: str = "xml"):
anystr = ffi.new("char **", ffi.NULL)
ret = lib.lyd_any_value_str(self.cdata, anystr)
ret = lib.lyd_any_value_str(self.cdata, data_format(fmt), anystr)
if ret != lib.LY_SUCCESS:
raise self.context.error("cannot get data")
return c2str(anystr[0])
Expand All @@ -1185,7 +1183,7 @@ def value(self, fmt: str = "xml"):
class DAnydata(DNode):
def value(self, fmt: str = "xml"):
anystr = ffi.new("char **", ffi.NULL)
ret = lib.lyd_any_value_str(self.cdata, anystr)
ret = lib.lyd_any_value_str(self.cdata, data_format(fmt), anystr)
if ret != lib.LY_SUCCESS:
raise self.context.error("cannot get data")
return c2str(anystr[0])
Expand Down
2 changes: 0 additions & 2 deletions libyang/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1885,8 +1885,6 @@ def iter_children_options(
options |= lib.LYS_GETNEXT_INTONPCONT
if output:
options |= lib.LYS_GETNEXT_OUTPUT
if with_schema_mount:
options |= lib.LYS_GETNEXT_WITHSCHEMAMOUNT
return options


Expand Down
11 changes: 8 additions & 3 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ def test_ctx_disable_searchdirs(self):

def test_ctx_using_clb(self):
def get_module_valid_clb(mod_name, *_):
YOLO_NODETYPES_MOD_PATH = os.path.join(YANG_DIR, "yolo/yolo-nodetypes.yang")
self.assertEqual(mod_name, "yolo-nodetypes")
with open(YOLO_NODETYPES_MOD_PATH, encoding="utf-8") as f:
MOD_PATHS = {
"yolo-nodetypes": os.path.join(YANG_DIR, "yolo/yolo-nodetypes.yang"),
"ietf-inet-types": os.path.join(
YANG_DIR, "ietf/ietf-inet-types@2013-07-15.yang"
),
}
self.assertIn(mod_name, MOD_PATHS)
with open(MOD_PATHS[mod_name], encoding="utf-8") as f:
mod_str = f.read()
return "yang", mod_str

Expand Down
10 changes: 4 additions & 6 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,19 @@ def test_data_parse_config_xml_multi_error(self):
self.assertEqual(
str(cm.exception),
'failed to parse data tree: Invalid boolean value "abcd".: '
"Data path: /yolo-system:conf/url[proto='https']/enabled (line 6): "
"Data path: /yolo-system:url[proto='https']/enabled (line 6): "
'List instance is missing its key "host".: '
"Data path: /yolo-system:conf/url[proto='https'] (line 7)",
"Data path: /yolo-system:url[proto='https'] (line 7)",
)

first = cm.exception.errors[0]
self.assertEqual(first.msg, 'Invalid boolean value "abcd".')
self.assertEqual(
first.data_path, "/yolo-system:conf/url[proto='https']/enabled"
)
self.assertEqual(first.data_path, "/yolo-system:url[proto='https']/enabled")
self.assertEqual(first.line, 6)

second = cm.exception.errors[1]
self.assertEqual(second.msg, 'List instance is missing its key "host".')
self.assertEqual(second.data_path, "/yolo-system:conf/url[proto='https']")
self.assertEqual(second.data_path, "/yolo-system:url[proto='https']")
self.assertEqual(second.line, 7)

XML_STATE = """<state xmlns="urn:yang:yolo:system">
Expand Down
Loading
Loading