.. module:: yangson.instance :synopsis: Persistent data instances.
.. testsetup:: import json import os from yangson import DataModel os.chdir("examples/ex2")
.. testcleanup:: os.chdir("../..")
The instance module implements the following classes:
- :class:`InstanceNode`: Abstract class for instance nodes.
- :class:`RootNode`: Root of the data tree.
- :class:`ObjectMember`: Instance node that is an object member.
- :class:`ArrayEntry`: Instance node that is an array entry.
- :class:`InstanceRoute`: Route into an instance value.
Doctest snippets for this module use the data model and instance document from :ref:`sec-ex2`.
>>> dm = DataModel.from_file('yang-library-ex2.json')
>>> with open('example-data.json') as infile:
... ri = json.load(infile)
>>> inst = dm.from_raw(ri)
.. autoclass:: RootNode(value: Value, schema_node: SchemaNode, timestamp: datetime.datetime) :show-inheritance:
.. autoclass:: InstanceRoute :show-inheritance: Instances of this class can be conveniently created by using one of the methods :meth:`~.DataModel.parse_resource_id` and :meth:`~.DataModel.parse_instance_id` in the :class:`~.datamodel.DataModel` class. .. rubric:: Public Methods .. automethod:: __str__ .. doctest:: >>> str(irt) '/example-2:bag/foo[number="3"]/in-words' >>> str(irt2) '/example-2:bag/baz'