17 Commits

Author SHA1 Message Date
Jan Kundrát
32b9ff8813 Port to libyang v3
...along with a bunch of incompatible API/ABI changes.

I had to make a few tweaks in the build process as well, and these
couldn't be made (and tested!) with separate commits. The test suite was
failing on OS X 13, so I decided to upgrade, because "why not".
2025-04-04 20:38:50 -07:00
Jan Kundrát
77db42ffa5 API change: sync with upstream repos
Warning, Context.get_module's API changed, the revision no longer
default to `None` because passing `None` explicitly asks for a module
with no associated revision. Use `Context.get_module_latest` when the
previous behavior is needed. This is a deliberate change from the C++
library; only in C++ a compiler catches this :).

See-also: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/6732
See-also: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/6733
2024-01-16 11:32:05 +01:00
Jan Kundrát
e629297a2d creating new data nodes 2023-09-01 17:59:11 +02:00
Jan Kundrát
2816765c14 Basic schema-level queries 2023-09-01 16:18:11 +02:00
Jan Kundrát
55ee7a14eb Allow easy checking for element existence 2023-09-01 16:18:11 +02:00
Jan Kundrát
96b2178d47 Add support for reading enumerations 2023-09-01 16:18:11 +02:00
Jan Kundrát
f85ec36353 Working with the empty type 2023-09-01 16:18:11 +02:00
Jan Kundrát
feae818234 Add support for reading the decimal64 data type 2023-09-01 16:06:34 +02:00
Jan Kundrát
f7b64f68e4 Add support for relative path lookup starting at root 2023-09-01 15:25:58 +02:00
Jan Kundrát
3a1bc911a8 Export DataNode::findPath with no restrictions on result size 2023-09-01 15:25:58 +02:00
Jan Kundrát
a825729856 use Python's default snake_case naming convention consistently 2023-09-01 15:25:57 +02:00
Jan Kundrát
52d22728df libyang: support backslashes in file names on Windows
There are some failures with `gnpy` on Windows:

 ================================== FAILURES ===================================
 ____________ test_lint_yang[ietf-network-topology@2018-02-26.yang] ____________

 yang_model = WindowsPath('D:/a/oopt-gnpy/oopt-gnpy/gnpy/yang/ext/ietf-network-topology@2018-02-26.yang')

     @pytest.mark.parametrize("yang_model", [x for x in external_path().glob('*.yang')] + [x for x in model_path().glob('*.yang')], ids=_get_basename)
     def test_lint_yang(yang_model):
         '''Run a linter on each YANG model'''
         c = ly.Context(str(external_path()) + os.pathsep + str(model_path()),
                        ly.ContextOptions.NoYangLibrary | ly.ContextOptions.DisableSearchCwd)
         assert c.parse_module(yang_model, ly.SchemaFormat.YANG) is not None
 >       assert c.errors() == []
 E       assert <[TypeError("unhashable type: 'instancemethod'") raised in repr()] list object at 0x1880e5958c0> == []
 E         (pytest_assertion plugin: representation of details failed: C:\hostedtoolcache\windows\Python\3.11.4\x64\Lib\pprint.py:178: TypeError: unhashable type: 'instancemethod'.
 E          Probably an object has a faulty __repr__.)

 tests\test_yang_lint.py:30: AssertionError
 ---------------------------- Captured stderr call -----------------------------
 libyang[1]: File name "D:\a\oopt-gnpy\oopt-gnpy\gnpy\yang\ext\ietf-network-topology@2018-02-26.yang" does not match module name "ietf-network-topology".
 ________________ test_lint_yang[ietf-network@2018-02-26.yang] _________________

That complaint about __repr__ is an impedance mismatch between pybind11
and Python (pybind/pybind11#2722), but in this case that whole thing is
triggered through a bug in libyang which assumes that the directory
separator is always `/`.

Bug: https://github.com/CESNET/libyang/pull/2093
2023-08-31 21:57:01 +02:00
Jan Kundrát
6bf5a8729b Export libyang version info
There's nothing like that in the libyang-cpp yet, so that one is not
made available.
2023-05-16 19:03:23 +02:00
Jan Kundrát
b6763ba61c explicit module loading without callbacks 2023-05-16 19:03:23 +02:00
Jan Kundrát
dc8e5259d3 Adapt to upstream C++ overloading 2023-05-16 19:03:23 +02:00
Jan Kundrát
3a458f2318 Python bindings: just enough to validate some YANG data 2022-07-01 00:52:53 +02:00
Jan Kundrát
717abdd01d Import some YANG modules for tests 2022-06-30 19:29:28 +02:00