Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print_file() throws when used with "with_siblings" #65

Open
tbsuht opened this issue Apr 22, 2024 · 1 comment
Open

print_file() throws when used with "with_siblings" #65

tbsuht opened this issue Apr 22, 2024 · 1 comment

Comments

@tbsuht
Copy link
Contributor

tbsuht commented Apr 22, 2024

>>> with sess.get_data_ly("/*") as data:
...    data.print_file(sys.stdout, fmt="json", pretty=True)
...
{

}
>>> with sess.get_data_ly("/ietf-hardware:*") as data:
...    data.print_file(sys.stdout, fmt="json", pretty=True)
...
{
  "ietf-hardware:hardware": {
    "component": [
      {
       ...
      }
    ]
  }
}
>>> with sess.get_data_ly("/*") as data:
...    data.print_file(sys.stdout, fmt="json", pretty=True, with_siblings=True)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/opt/venv/rmi/lib/python3.11/site-packages/libyang/data.py", line 676, in print_file
    raise self.context.error("cannot print node")
libyang.util.LibyangError: cannot print node
>>>

I'm not sure why the first call returns an empty object, as ietf-hardware contains data? And with the with_siblings option set, the call is crashing.

@tbsuht
Copy link
Contributor Author

tbsuht commented Apr 22, 2024

>>> with sess.get_data_ly("/*") as data:
...    data.print(fmt="json", out_type=IOType.MEMORY, pretty=True, with_siblings=True)
...
'{\n  "ietf-hardware:hardware": {\n    "component": [\n      {\n        ... \n      }\n    ]\n  },\n  "ietf-interfaces:interfaces": {\n    "interface": [\n      {\n        ... \n              }\n            ]\n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant