Skip to content

Latest commit

 

History

History
692 lines (499 loc) · 22.7 KB

instance.rst

File metadata and controls

692 lines (499 loc) · 22.7 KB

Persistent Data Instances

.. 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:

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'