|
4 | 4 | # SPDX-License-Identifier: MIT |
5 | 5 |
|
6 | 6 | 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 |
8 | 8 |
|
9 | 9 | from _libyang import ffi, lib |
10 | 10 | from .data import ( |
|
16 | 16 | validation_flags, |
17 | 17 | ) |
18 | 18 | from .schema import Module, SNode, schema_in_format |
19 | | -from .util import DataType, IOType, LibyangError, c2str, data_load, str2c |
| 19 | +from .util import DataType, IOType, LibyangError, c2str, data_load, str2c, strlist2c |
20 | 20 |
|
21 | 21 |
|
22 | 22 | # ------------------------------------------------------------------------------------- |
@@ -338,10 +338,19 @@ def parse_module_file( |
338 | 338 | def parse_module_str(self, s: str, fmt: str = "yang", features=None) -> Module: |
339 | 339 | return self.parse_module(s, IOType.MEMORY, fmt, features) |
340 | 340 |
|
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: |
342 | 347 | if self.cdata is None: |
343 | 348 | 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) |
345 | 354 | if mod == ffi.NULL: |
346 | 355 | raise self.error("cannot load module") |
347 | 356 |
|
|
0 commit comments