Skip to content

Commit c5af681

Browse files
rbu9ferjarry
authored andcommitted
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 <[email protected]>
1 parent bdd4cea commit c5af681

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libyang/context.py

+12-3
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 (
@@ -340,10 +340,19 @@ def parse_module_file(
340340
def parse_module_str(self, s: str, fmt: str = "yang", features=None) -> Module:
341341
return self.parse_module(s, IOType.MEMORY, fmt, features)
342342

343-
def load_module(self, name: str) -> Module:
343+
def load_module(
344+
self,
345+
name: str,
346+
revision: Optional[str] = None,
347+
enabled_features: Sequence[str] = (),
348+
) -> Module:
344349
if self.cdata is None:
345350
raise RuntimeError("context already destroyed")
346-
mod = lib.ly_ctx_load_module(self.cdata, str2c(name), ffi.NULL, ffi.NULL)
351+
if enabled_features:
352+
features = tuple([str2c(f) for f in enabled_features] + [ffi.NULL])
353+
else:
354+
features = ffi.NULL
355+
mod = lib.ly_ctx_load_module(self.cdata, str2c(name), str2c(revision), features)
347356
if mod == ffi.NULL:
348357
raise self.error("cannot load module")
349358

0 commit comments

Comments
 (0)