Skip to content

Commit c316055

Browse files
committed
load_module: add missing parameters for ly_ctx_load_module
Add parameters to define Yang model revision and features that shall be enabled. Closes: #101 Signed-off-by: Matthias Breuninger <matthias.breuninger@etas.com>
1 parent 76504c4 commit c316055

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libyang/context.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: MIT
55

66
import os
7-
from typing import IO, Any, Callable, Iterator, Optional, Tuple, Union
7+
from typing import IO, Any, Callable, Iterator, Optional, Sequence, Tuple, Union
88

99
from _libyang import ffi, lib
1010
from .data import (
@@ -338,10 +338,19 @@ def parse_module_file(
338338
def parse_module_str(self, s: str, fmt: str = "yang", features=None) -> Module:
339339
return self.parse_module(s, IOType.MEMORY, fmt, features)
340340

341-
def load_module(self, name: str) -> Module:
341+
def load_module(
342+
self,
343+
name: str,
344+
revision: Optional[str] = None,
345+
enabled_features: Sequence[str] = (),
346+
) -> Module:
342347
if self.cdata is None:
343348
raise RuntimeError("context already destroyed")
344-
mod = lib.ly_ctx_load_module(self.cdata, str2c(name), ffi.NULL, ffi.NULL)
349+
if enabled_features:
350+
features = tuple([str2c(f) for f in enabled_features] + [ffi.NULL])
351+
else:
352+
features = ffi.NULL
353+
mod = lib.ly_ctx_load_module(self.cdata, str2c(name), str2c(revision), features)
345354
if mod == ffi.NULL:
346355
raise self.error("cannot load module")
347356

0 commit comments

Comments
 (0)