mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-12 14:18:43 +00:00
25 lines
535 B
Python
25 lines
535 B
Python
|
from yangson import DataModel
|
||
|
import cbor
|
||
|
import json
|
||
|
import sys
|
||
|
|
||
|
class Message:
|
||
|
def __init__(self, filename):
|
||
|
self.filename = filename
|
||
|
with open(self.filename) as sf:
|
||
|
self.raw = json.load(sf)
|
||
|
|
||
|
self.dm = DataModel.from_file('yang-library.json')
|
||
|
self.data = self.dm.from_raw(self.raw)
|
||
|
self.data.validate()
|
||
|
|
||
|
#print(sys.argv[1])
|
||
|
|
||
|
msg = Message(sys.argv[1])
|
||
|
#print(msg, msg.raw)
|
||
|
#print(cbor.dumps(msg.raw))
|
||
|
with open(sys.argv[2], "wb") as of:
|
||
|
cbor.dump(msg.raw, of)
|
||
|
|
||
|
print("OK")
|