Skip to content
Snippets Groups Projects
Commit 8d5f5ec4 authored by Ladislav Lhotka's avatar Ladislav Lhotka
Browse files

Implement class method Context::module_set_id.

parent 5cfc1e94
No related branches found
No related tags found
No related merge requests found
{
"ietf-yang-library:modules-state": {
"module-set-id": "TO-BE-INVENTED",
"module-set-id": "b6d7e0614440c5ad8a7370fe46c777254d331983",
"module": [
{
"name": "testb",
......
......@@ -10,7 +10,7 @@ def contents(*filenames):
setup(
name = "yangson",
packages = ["yangson"],
version = "0.1.50",
version = "0.1.51",
description = "Library for working with YANG schemas and data",
author = "Ladislav Lhotka",
author_email = "lhotka@nic.cz",
......
......@@ -122,6 +122,7 @@ def instance(data_model):
def test_context(data_model):
assert len(Context.implement) == 3
assert Context.module_set_id() == "b6d7e0614440c5ad8a7370fe46c777254d331983"
tid = Context._last_revision("test")
stid = Context._last_revision("subtest")
tbid = Context._last_revision("testb")
......
import hashlib
import re
from typing import Dict, List, MutableSet
from .constants import pname_re, YangsonException
......@@ -94,6 +95,13 @@ class Context:
cls.schema._post_process()
cls.schema._make_schema_patterns()
@classmethod
def module_set_id(cls):
"""Return numeric id of the current set of modules."""
fnames = ["@".join(m) for m in cls.modules.keys()]
fnames.sort()
return hashlib.sha1("".join(fnames).encode("ascii")).hexdigest()
@classmethod
def _load_module(cls, name: YangIdentifier,
rev: RevisionDate) -> Statement:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment