diff --git a/Makefile b/Makefile index 97e9121afbe9b72615518217eb927180f70478dd..ff93581144936c5ff80f9be4188b9f5eaac589a8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROJECT = yangson -VERSION = 1.3.15 +VERSION = 1.3.16 .PHONY = tags deps install-deps test tags: diff --git a/docs/datamodel.rst b/docs/datamodel.rst index aad06bea24504f627040d69181b051177f9db881..8565368c4b758234522a3fbf307efaf6d0214742 100644 --- a/docs/datamodel.rst +++ b/docs/datamodel.rst @@ -60,6 +60,20 @@ __ http://www.sphinx-doc.org/en/stable/ext/doctest.html >>> from yangson import DataModel + .. rubric:: Instance Attributes + + .. attribute:: schema + + Root node of the schema tree. + + .. attribute:: schema_data + + Object describing various properties extracted from the data model. + + .. attribute:: yang_library + + Python dictionary containing parsed YANG library data. + .. rubric:: Public Methods .. classmethod:: from_file(name: str, mod_path: List[str] = ["."], \ @@ -77,6 +91,8 @@ __ http://www.sphinx-doc.org/en/stable/ext/doctest.html .. doctest:: >>> dm = DataModel.from_file("yang-library-ex1.json") + >>> dm.yang_library['ietf-yang-library:modules-state']['module-set-id'] + 'ae4bf1ddf85a67ab94a9ab71593cd1c78b7f231d' .. method:: module_set_id() -> str diff --git a/yangson/datamodel.py b/yangson/datamodel.py index acf78ec2b9555387f0604305b55785ba1729aea6..36604c7787091b317de2d16f1052f8333ee963e8 100644 --- a/yangson/datamodel.py +++ b/yangson/datamodel.py @@ -78,13 +78,14 @@ class DataModel: self.schema = SchemaTreeNode() self.schema._ctype = ContentType.all try: - yl = json.loads(yltxt) + self.yang_library = json.loads(yltxt) except json.JSONDecodeError as e: raise BadYangLibraryData(str(e)) from None - self.schema_data = SchemaData(yl, mod_path) + self.schema_data = SchemaData(self.yang_library, mod_path) self._build_schema() self.schema.description = description if description else ( - "Data model ID: " + yl["ietf-yang-library:modules-state"]["module-set-id"]) + "Data model ID: " + + self.yang_library["ietf-yang-library:modules-state"]["module-set-id"]) def module_set_id(self) -> str: """Compute unique id of YANG modules comprising the data model.