0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 02:01:55 +00:00
bird/yang/JSON_CBOR.py

15 lines
405 B
Python
Raw Normal View History

2023-11-15 12:56:37 +00:00
from yangson import DataModel
import cbor
import json
class Message:
def __init__(self, filename, _type):
self.filename = filename
with open(self.filename, "rb") as sf:
self.raw = { "json": json, "cbor": cbor }[_type].load(sf)
self.dm = DataModel.from_file('yang-library.json')
self.data = self.dm.from_raw(self.raw)
self.data.validate()